130 lines
6.0 KiB
C#
130 lines
6.0 KiB
C#
using System;
|
|
using Distribution.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Distribution.Migrations
|
|
{
|
|
[DbContext(typeof(AppDBContext))]
|
|
[Migration("20260821120000_AddPromotionsSchemes")]
|
|
/// <inheritdoc />
|
|
public partial class AddPromotionsSchemes : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<decimal>(
|
|
name: "CostPrice",
|
|
table: "Items",
|
|
type: "decimal(65,30)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Schemes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
RuleType = table.Column<int>(type: "int", nullable: false),
|
|
RuleConfig = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_RegionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
EligibleSegment = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
DateRangeFrom = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
DateRangeTo = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
AgentLimitExempt = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
BaselineExpectedSales = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Schemes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Schemes_Regions_FK_RegionId",
|
|
column: x => x.FK_RegionId,
|
|
principalTable: "Regions",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SchemeRedemptions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SchemeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_OrderId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FieldInvoiceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
DiscountAmount = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
FK_FreeItemId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FreeQty = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
FreeItemCostValue = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
RedeemedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SchemeRedemptions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Schemes_FK_SchemeId",
|
|
column: x => x.FK_SchemeId,
|
|
principalTable: "Schemes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Orders_FK_OrderId",
|
|
column: x => x.FK_OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Items_FK_FreeItemId",
|
|
column: x => x.FK_FreeItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Schemes_FK_RegionId",
|
|
table: "Schemes",
|
|
column: "FK_RegionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_SchemeId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_SchemeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_OrderId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_FreeItemId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_FreeItemId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "SchemeRedemptions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Schemes");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CostPrice",
|
|
table: "Items");
|
|
}
|
|
}
|
|
}
|