using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace PartSource.Data.Migrations { public partial class ImportDateDcfMapping : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "Vehicle"); migrationBuilder.CreateTable( name: "ApiClient", columns: table => new { Key = table.Column(nullable: false), AppName = table.Column(nullable: true), Secret = table.Column(nullable: true), Active = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ApiClient", x => x.Key); }); migrationBuilder.CreateTable( name: "Fitment", columns: table => new { FitmentId = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), ManufacturerCode = table.Column(nullable: true), PartNumber = table.Column(nullable: true), PartLabel = table.Column(nullable: true), BaseVehicleId = table.Column(nullable: true), EngineConfigId = table.Column(nullable: true), NoteText = table.Column(nullable: true), Position = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Fitment", x => x.FitmentId); }); migrationBuilder.CreateTable( name: "ImportData", columns: table => new { VariantSku = table.Column(nullable: false), Title = table.Column(nullable: true), BodyHtml = table.Column(nullable: true), Vendor = table.Column(nullable: true), IsVariant = table.Column(nullable: true), VariantTitle = table.Column(nullable: true), Price = table.Column(nullable: false), CompareAt = table.Column(nullable: false), ShopifyId = table.Column(nullable: true), ImageSrc = table.Column(nullable: true), ImageAltText = table.Column(nullable: true), IsFitment = table.Column(nullable: true), LineCode = table.Column(nullable: true), PartNumber = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ImportData", x => x.VariantSku); }); migrationBuilder.CreateTable( name: "ImportMetric", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), TotalItems = table.Column(nullable: true), ChangedItems = table.Column(nullable: true), ImportDate = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ImportMetric", x => x.Id); }); migrationBuilder.CreateTable( name: "Manufacturer", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Name = table.Column(nullable: true), LineCode = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Manufacturer", x => x.Id); }); migrationBuilder.CreateTable( name: "PartData", columns: table => new { SKU = table.Column(maxLength: 255, nullable: false), LOB_NM = table.Column(maxLength: 255, nullable: true), CATEGORY_NM = table.Column(maxLength: 255, nullable: true), SUBCATEGORY_NM = table.Column(maxLength: 255, nullable: true), FINELINE_NM = table.Column(maxLength: 255, nullable: true), PRODUCT_ENGLISH_LONG_DESC = table.Column(maxLength: 255, nullable: true), BRAND_NM = table.Column(maxLength: 255, nullable: true), CORPORATE_STATUS_NM = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS1 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS2 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS3 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS4 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS5 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS6 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS7 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS8 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS9 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS10 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS11 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS12 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS13 = table.Column(maxLength: 255, nullable: true), FAMILY_FEATURES_BENEFITS14 = table.Column(maxLength: 255, nullable: true), Tested = table.Column(maxLength: 255, nullable: true), LineCode = table.Column(name: "Line Code", maxLength: 255, nullable: true), PartNumber = table.Column(name: "Part Number", maxLength: 255, nullable: true), ComparePrice = table.Column(name: "Compare Price", type: "money", nullable: true), YourPrice = table.Column(name: "Your Price", type: "money", nullable: true), Title = table.Column(nullable: true), VariantTitle = table.Column(nullable: true), IsFitment = table.Column(nullable: true), Published = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PartData", x => x.SKU); }); migrationBuilder.CreateTable( name: "PartImage", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Sku = table.Column(nullable: true), Url = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PartImage", x => x.Id); }); migrationBuilder.CreateTable( name: "PartPrice", columns: table => new { SKU = table.Column(nullable: false), Compare_Price = table.Column(nullable: true), Your_Price = table.Column(nullable: true), Active = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PartPrice", x => x.SKU); }); migrationBuilder.CreateTable( name: "PartsAvailability", columns: table => new { Store = table.Column(nullable: false), SKU = table.Column(nullable: false), LineCode = table.Column(name: "Line Code", maxLength: 50, nullable: true), PartNumber = table.Column(name: "Part Number", maxLength: 50, nullable: true), QTY = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PartsAvailability", x => new { x.Store, x.SKU }); }); migrationBuilder.CreateTable( name: "BaseVehicle", schema: "Vehicle", columns: table => new { Id = table.Column(nullable: false), Year = table.Column(nullable: false), VehicleMakeId = table.Column(nullable: false), VehicleModelId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_BaseVehicle", x => x.Id); }); migrationBuilder.CreateTable( name: "Submodel", schema: "Vehicle", columns: table => new { VehicleToEngineConfigId = table.Column(nullable: false), SubmodelId = table.Column(nullable: false), BaseVehicleId = table.Column(nullable: false), EngineId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Submodel", x => x.VehicleToEngineConfigId); }); migrationBuilder.CreateTable( name: "VehicleEngine", schema: "Vehicle", columns: table => new { Id = table.Column(nullable: false), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_VehicleEngine", x => x.Id); }); migrationBuilder.CreateTable( name: "VehicleMake", schema: "Vehicle", columns: table => new { Id = table.Column(nullable: false), Name = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_VehicleMake", x => x.Id); }); migrationBuilder.CreateTable( name: "VehicleModel", schema: "Vehicle", columns: table => new { Id = table.Column(nullable: false), Name = table.Column(nullable: true), VehicleMakeId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_VehicleModel", x => x.Id); }); migrationBuilder.CreateTable( name: "DcfMapping", columns: table => new { LineCode = table.Column(nullable: false), WhiCode = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_DcfMapping", x => new { x.LineCode, x.WhiCode }); table.ForeignKey( name: "FK_DcfMapping_ImportData_LineCode", column: x => x.LineCode, principalTable: "ImportData", principalColumn: "VariantSku", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Part", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), ManufacturerId = table.Column(nullable: false), ShopifyId = table.Column(nullable: true), Sku = table.Column(nullable: false), PartNumber = table.Column(nullable: true), Name = table.Column(nullable: true), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Part", x => x.Id); table.ForeignKey( name: "FK_Part_Manufacturer_ManufacturerId", column: x => x.ManufacturerId, principalTable: "Manufacturer", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Part_ManufacturerId", table: "Part", column: "ManufacturerId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ApiClient"); migrationBuilder.DropTable( name: "DcfMapping"); migrationBuilder.DropTable( name: "Fitment"); migrationBuilder.DropTable( name: "ImportMetric"); migrationBuilder.DropTable( name: "Part"); migrationBuilder.DropTable( name: "PartData"); migrationBuilder.DropTable( name: "PartImage"); migrationBuilder.DropTable( name: "PartPrice"); migrationBuilder.DropTable( name: "PartsAvailability"); migrationBuilder.DropTable( name: "BaseVehicle", schema: "Vehicle"); migrationBuilder.DropTable( name: "Submodel", schema: "Vehicle"); migrationBuilder.DropTable( name: "VehicleEngine", schema: "Vehicle"); migrationBuilder.DropTable( name: "VehicleMake", schema: "Vehicle"); migrationBuilder.DropTable( name: "VehicleModel", schema: "Vehicle"); migrationBuilder.DropTable( name: "ImportData"); migrationBuilder.DropTable( name: "Manufacturer"); } } }