using Microsoft.EntityFrameworkCore.Migrations; using MySql.EntityFrameworkCore.Metadata; namespace InventoryManager.Migrations { public partial class initialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Collections", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Description = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Collections", x => x.Id); }); migrationBuilder.CreateTable( name: "Colors", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Description = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Colors", x => x.Id); }); migrationBuilder.CreateTable( name: "Suppliers", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Address = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false), Contact = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false), Inforamtion = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Suppliers", x => x.Id); }); migrationBuilder.CreateTable( name: "Units", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Description = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Units", x => x.Id); }); migrationBuilder.CreateTable( name: "Materials", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Description = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false), Supplier = table.Column<int>(type: "int", nullable: false), Unit = table.Column<int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Materials", x => x.Id); table.ForeignKey( name: "FK_Materials_Suppliers_Supplier", column: x => x.Supplier, principalTable: "Suppliers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Materials_Units_Unit", column: x => x.Unit, principalTable: "Units", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Products", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Description = table.Column<string>(type: "varchar(75)", maxLength: 75, nullable: false), Color = table.Column<int>(type: "int", nullable: false), Quantity = table.Column<string>(type: "varchar(25)", maxLength: 25, nullable: false), Unit = table.Column<int>(type: "int", nullable: false), Collection = table.Column<int>(type: "int", nullable: false), Material = table.Column<int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); table.ForeignKey( name: "FK_Products_Collections_Collection", column: x => x.Collection, principalTable: "Collections", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Products_Colors_Color", column: x => x.Color, principalTable: "Colors", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Products_Materials_Material", column: x => x.Material, principalTable: "Materials", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Products_Units_Unit", column: x => x.Unit, principalTable: "Units", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Materials_Supplier", table: "Materials", column: "Supplier"); migrationBuilder.CreateIndex( name: "IX_Materials_Unit", table: "Materials", column: "Unit"); migrationBuilder.CreateIndex( name: "IX_Products_Collection", table: "Products", column: "Collection"); migrationBuilder.CreateIndex( name: "IX_Products_Color", table: "Products", column: "Color"); migrationBuilder.CreateIndex( name: "IX_Products_Material", table: "Products", column: "Material"); migrationBuilder.CreateIndex( name: "IX_Products_Unit", table: "Products", column: "Unit"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "Collections"); migrationBuilder.DropTable( name: "Colors"); migrationBuilder.DropTable( name: "Materials"); migrationBuilder.DropTable( name: "Suppliers"); migrationBuilder.DropTable( name: "Units"); } } }