Sky.Net/Infrastructure/Data/Migrations/20220509234932_InitialCreate.cs

91 lines
3.5 KiB
C#
Raw Normal View History

2022-05-09 17:07:59 -07:00
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Data.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProductBrands",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductBrands", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ProductTypes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
Description = table.Column<string>(type: "TEXT", nullable: true),
Price = table.Column<decimal>(type: "TEXT", nullable: false),
PictureUrl = table.Column<string>(type: "TEXT", nullable: true),
ProductTypeId = table.Column<int>(type: "INTEGER", nullable: false),
ProductBrandId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
table.ForeignKey(
name: "FK_Products_ProductBrands_ProductBrandId",
column: x => x.ProductBrandId,
principalTable: "ProductBrands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Products_ProductTypes_ProductTypeId",
column: x => x.ProductTypeId,
principalTable: "ProductTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Products_ProductBrandId",
table: "Products",
column: "ProductBrandId");
migrationBuilder.CreateIndex(
name: "IX_Products_ProductTypeId",
table: "Products",
column: "ProductTypeId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "ProductBrands");
migrationBuilder.DropTable(
name: "ProductTypes");
}
}
}