You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using MySql.EntityFrameworkCore.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace InventoryManagement_MariaDB.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class initialize : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
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(255)", nullable: false),
|
|
Quantity = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "longtext", nullable: false),
|
|
Description = table.Column<string>(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);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Accessaries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Products");
|
|
}
|
|
}
|
|
}
|
|
|