76 lines
2.8 KiB
C#
76 lines
2.8 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CocktailWeb.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class CreateCocktailTable : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Cocktails",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Cocktails", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CocktailFlaschen",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
CocktailID = table.Column<int>(type: "INTEGER", nullable: false),
|
|
FlascheID = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Reihenfolge = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Menge = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CocktailFlaschen", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CocktailFlaschen_Cocktails_CocktailID",
|
|
column: x => x.CocktailID,
|
|
principalTable: "Cocktails",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CocktailFlaschen_Flaschen_FlascheID",
|
|
column: x => x.FlascheID,
|
|
principalTable: "Flaschen",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CocktailFlaschen_CocktailID",
|
|
table: "CocktailFlaschen",
|
|
column: "CocktailID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CocktailFlaschen_FlascheID",
|
|
table: "CocktailFlaschen",
|
|
column: "FlascheID");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CocktailFlaschen");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Cocktails");
|
|
}
|
|
}
|
|
}
|