Files
Partsource/PartSource.Data/Migrations/20190811020941_ImportDateDcfMapping.cs
2020-04-12 20:52:03 -04:00

359 lines
16 KiB
C#

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<string>(nullable: false),
AppName = table.Column<string>(nullable: true),
Secret = table.Column<string>(nullable: true),
Active = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiClient", x => x.Key);
});
migrationBuilder.CreateTable(
name: "Fitment",
columns: table => new
{
FitmentId = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ManufacturerCode = table.Column<string>(nullable: true),
PartNumber = table.Column<string>(nullable: true),
PartLabel = table.Column<string>(nullable: true),
BaseVehicleId = table.Column<int>(nullable: true),
EngineConfigId = table.Column<int>(nullable: true),
NoteText = table.Column<string>(nullable: true),
Position = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Fitment", x => x.FitmentId);
});
migrationBuilder.CreateTable(
name: "ImportData",
columns: table => new
{
VariantSku = table.Column<string>(nullable: false),
Title = table.Column<string>(nullable: true),
BodyHtml = table.Column<string>(nullable: true),
Vendor = table.Column<string>(nullable: true),
IsVariant = table.Column<bool>(nullable: true),
VariantTitle = table.Column<string>(nullable: true),
Price = table.Column<decimal>(nullable: false),
CompareAt = table.Column<decimal>(nullable: false),
ShopifyId = table.Column<long>(nullable: true),
ImageSrc = table.Column<string>(nullable: true),
ImageAltText = table.Column<string>(nullable: true),
IsFitment = table.Column<bool>(nullable: true),
LineCode = table.Column<string>(nullable: true),
PartNumber = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ImportData", x => x.VariantSku);
});
migrationBuilder.CreateTable(
name: "ImportMetric",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
TotalItems = table.Column<int>(nullable: true),
ChangedItems = table.Column<int>(nullable: true),
ImportDate = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ImportMetric", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Manufacturer",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true),
LineCode = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturer", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PartData",
columns: table => new
{
SKU = table.Column<string>(maxLength: 255, nullable: false),
LOB_NM = table.Column<string>(maxLength: 255, nullable: true),
CATEGORY_NM = table.Column<string>(maxLength: 255, nullable: true),
SUBCATEGORY_NM = table.Column<string>(maxLength: 255, nullable: true),
FINELINE_NM = table.Column<string>(maxLength: 255, nullable: true),
PRODUCT_ENGLISH_LONG_DESC = table.Column<string>(maxLength: 255, nullable: true),
BRAND_NM = table.Column<string>(maxLength: 255, nullable: true),
CORPORATE_STATUS_NM = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS1 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS2 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS3 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS4 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS5 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS6 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS7 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS8 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS9 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS10 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS11 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS12 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS13 = table.Column<string>(maxLength: 255, nullable: true),
FAMILY_FEATURES_BENEFITS14 = table.Column<string>(maxLength: 255, nullable: true),
Tested = table.Column<string>(maxLength: 255, nullable: true),
LineCode = table.Column<string>(name: "Line Code", maxLength: 255, nullable: true),
PartNumber = table.Column<string>(name: "Part Number", maxLength: 255, nullable: true),
ComparePrice = table.Column<decimal>(name: "Compare Price", type: "money", nullable: true),
YourPrice = table.Column<decimal>(name: "Your Price", type: "money", nullable: true),
Title = table.Column<string>(nullable: true),
VariantTitle = table.Column<string>(nullable: true),
IsFitment = table.Column<byte>(nullable: true),
Published = table.Column<byte>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PartData", x => x.SKU);
});
migrationBuilder.CreateTable(
name: "PartImage",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Sku = table.Column<string>(nullable: true),
Url = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PartImage", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PartPrice",
columns: table => new
{
SKU = table.Column<string>(nullable: false),
Compare_Price = table.Column<decimal>(nullable: true),
Your_Price = table.Column<decimal>(nullable: true),
Active = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PartPrice", x => x.SKU);
});
migrationBuilder.CreateTable(
name: "PartsAvailability",
columns: table => new
{
Store = table.Column<int>(nullable: false),
SKU = table.Column<int>(nullable: false),
LineCode = table.Column<string>(name: "Line Code", maxLength: 50, nullable: true),
PartNumber = table.Column<string>(name: "Part Number", maxLength: 50, nullable: true),
QTY = table.Column<int>(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<int>(nullable: false),
Year = table.Column<int>(nullable: false),
VehicleMakeId = table.Column<int>(nullable: false),
VehicleModelId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BaseVehicle", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Submodel",
schema: "Vehicle",
columns: table => new
{
VehicleToEngineConfigId = table.Column<int>(nullable: false),
SubmodelId = table.Column<int>(nullable: false),
BaseVehicleId = table.Column<int>(nullable: false),
EngineId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Submodel", x => x.VehicleToEngineConfigId);
});
migrationBuilder.CreateTable(
name: "VehicleEngine",
schema: "Vehicle",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleEngine", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleMake",
schema: "Vehicle",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleMake", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleModel",
schema: "Vehicle",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
VehicleMakeId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleModel", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DcfMapping",
columns: table => new
{
LineCode = table.Column<string>(nullable: false),
WhiCode = table.Column<string>(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<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ManufacturerId = table.Column<int>(nullable: false),
ShopifyId = table.Column<long>(nullable: true),
Sku = table.Column<int>(nullable: false),
PartNumber = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(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");
}
}
}