200 lines
9.6 KiB
C#
200 lines
9.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace PowderCoating.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddGiftCertificates : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<decimal>(
|
|
name: "GiftCertificateRedeemed",
|
|
table: "Invoices",
|
|
type: "decimal(18,2)",
|
|
nullable: false,
|
|
defaultValue: 0m);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GiftCertificates",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
CertificateCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
OriginalAmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
RedeemedAmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
RecipientCustomerId = table.Column<int>(type: "int", nullable: true),
|
|
RecipientName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
RecipientEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IssuedReason = table.Column<int>(type: "int", nullable: false),
|
|
PurchasePrice = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
|
|
PurchasingCustomerId = table.Column<int>(type: "int", nullable: true),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
IssueDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
ExpiryDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IssuedById = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
|
CompanyId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GiftCertificates", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificates_AspNetUsers_IssuedById",
|
|
column: x => x.IssuedById,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificates_Customers_PurchasingCustomerId",
|
|
column: x => x.PurchasingCustomerId,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificates_Customers_RecipientCustomerId",
|
|
column: x => x.RecipientCustomerId,
|
|
principalTable: "Customers",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GiftCertificateRedemptions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
GiftCertificateId = table.Column<int>(type: "int", nullable: false),
|
|
InvoiceId = table.Column<int>(type: "int", nullable: false),
|
|
AmountRedeemed = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
RedeemedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
RedeemedById = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
|
CompanyId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GiftCertificateRedemptions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificateRedemptions_AspNetUsers_RedeemedById",
|
|
column: x => x.RedeemedById,
|
|
principalTable: "AspNetUsers",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificateRedemptions_GiftCertificates_GiftCertificateId",
|
|
column: x => x.GiftCertificateId,
|
|
principalTable: "GiftCertificates",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_GiftCertificateRedemptions_Invoices_InvoiceId",
|
|
column: x => x.InvoiceId,
|
|
principalTable: "Invoices",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 15, 45, 3, 145, DateTimeKind.Utc).AddTicks(4465));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 15, 45, 3, 145, DateTimeKind.Utc).AddTicks(4472));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 15, 45, 3, 145, DateTimeKind.Utc).AddTicks(4474));
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificateRedemptions_GiftCertificateId",
|
|
table: "GiftCertificateRedemptions",
|
|
column: "GiftCertificateId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificateRedemptions_InvoiceId",
|
|
table: "GiftCertificateRedemptions",
|
|
column: "InvoiceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificateRedemptions_RedeemedById",
|
|
table: "GiftCertificateRedemptions",
|
|
column: "RedeemedById");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificates_IssuedById",
|
|
table: "GiftCertificates",
|
|
column: "IssuedById");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificates_PurchasingCustomerId",
|
|
table: "GiftCertificates",
|
|
column: "PurchasingCustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GiftCertificates_RecipientCustomerId",
|
|
table: "GiftCertificates",
|
|
column: "RecipientCustomerId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "GiftCertificateRedemptions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "GiftCertificates");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "GiftCertificateRedeemed",
|
|
table: "Invoices");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5291));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5296));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5298));
|
|
}
|
|
}
|
|
}
|