using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Distribution.Migrations { /// public partial class AddPricingAndSuppliers : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "PriceLists", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FK_RegionId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), EffectiveFrom = table.Column(type: "datetime(6)", nullable: false), EffectiveTo = table.Column(type: "datetime(6)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PriceLists", x => x.Id); table.ForeignKey( name: "FK_PriceLists_Regions_FK_RegionId", column: x => x.FK_RegionId, principalTable: "Regions", principalColumn: "Id"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Suppliers", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ContactInfo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PerformanceScore = table.Column(type: "decimal(65,30)", nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Suppliers", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "PriceListItems", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FK_PriceListId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Price = table.Column(type: "decimal(65,30)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), IsActive = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PriceListItems", x => x.Id); table.ForeignKey( name: "FK_PriceListItems_Items_FK_ItemId", column: x => x.FK_ItemId, principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PriceListItems_PriceLists_FK_PriceListId", column: x => x.FK_PriceListId, principalTable: "PriceLists", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_PriceListItems_FK_ItemId", table: "PriceListItems", column: "FK_ItemId"); migrationBuilder.CreateIndex( name: "IX_PriceListItems_FK_PriceListId_FK_ItemId", table: "PriceListItems", columns: new[] { "FK_PriceListId", "FK_ItemId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_PriceLists_FK_RegionId", table: "PriceLists", column: "FK_RegionId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PriceListItems"); migrationBuilder.DropTable( name: "Suppliers"); migrationBuilder.DropTable( name: "PriceLists"); } } }