using Microsoft.EntityFrameworkCore.Migrations; using MySql.EntityFrameworkCore.Metadata; #nullable disable namespace InventoryManagement_MariaDB.Migrations { /// public partial class initialize : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Products", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "varchar(255)", nullable: false), Quantity = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "Accessaries", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), ProductId = table.Column(type: "int", nullable: false), Name = table.Column(type: "longtext", nullable: false), Description = table.Column(type: "longtext", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Accessaries", x => x.Id); table.ForeignKey( name: "FK_Accessaries_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Accessaries_ProductId", table: "Accessaries", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Products_Name", table: "Products", column: "Name", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Accessaries"); migrationBuilder.DropTable( name: "Products"); } } }