Files
Kansan/KanSan/Migrations/20200213193512_InitialCommit.cs
2020-02-13 20:35:51 +01:00

120 lines
5.0 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace KanSan.Migrations
{
public partial class InitialCommit : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Kunden",
columns: table => new
{
KundenID = table.Column<Guid>(nullable: false),
Vorname = table.Column<string>(nullable: true),
Nachname = table.Column<string>(nullable: true),
Strasse = table.Column<string>(nullable: true),
PLZ = table.Column<string>(nullable: true),
Ort = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Kunden", x => x.KundenID);
});
migrationBuilder.CreateTable(
name: "Leistungsverzeichnisses",
columns: table => new
{
LeistungsverzeichnissID = table.Column<Guid>(nullable: false),
Position = table.Column<string>(nullable: true),
PositionBeschreibung = table.Column<string>(nullable: true),
PositionEinheit = table.Column<string>(nullable: true),
PositionEinheitspreis = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Leistungsverzeichnisses", x => x.LeistungsverzeichnissID);
});
migrationBuilder.CreateTable(
name: "Baustellen",
columns: table => new
{
BaustelleID = table.Column<Guid>(nullable: false),
Ort = table.Column<string>(nullable: true),
Strasse = table.Column<string>(nullable: true),
KundenID = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Baustellen", x => x.BaustelleID);
table.ForeignKey(
name: "FK_Baustellen_Kunden_KundenID",
column: x => x.KundenID,
principalTable: "Kunden",
principalColumn: "KundenID",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "LeistungsverzeichnisBaustelle",
columns: table => new
{
LeistungsverzeichnisBaustelleID = table.Column<int>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BaustelleID = table.Column<Guid>(nullable: true),
LeistungsverzeichnissID = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_LeistungsverzeichnisBaustelle", x => x.LeistungsverzeichnisBaustelleID);
table.ForeignKey(
name: "FK_LeistungsverzeichnisBaustelle_Baustellen_BaustelleID",
column: x => x.BaustelleID,
principalTable: "Baustellen",
principalColumn: "BaustelleID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_LeistungsverzeichnisBaustelle_Leistungsverzeichnisses_Leist~",
column: x => x.LeistungsverzeichnissID,
principalTable: "Leistungsverzeichnisses",
principalColumn: "LeistungsverzeichnissID",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Baustellen_KundenID",
table: "Baustellen",
column: "KundenID");
migrationBuilder.CreateIndex(
name: "IX_LeistungsverzeichnisBaustelle_BaustelleID",
table: "LeistungsverzeichnisBaustelle",
column: "BaustelleID");
migrationBuilder.CreateIndex(
name: "IX_LeistungsverzeichnisBaustelle_LeistungsverzeichnissID",
table: "LeistungsverzeichnisBaustelle",
column: "LeistungsverzeichnissID");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LeistungsverzeichnisBaustelle");
migrationBuilder.DropTable(
name: "Baustellen");
migrationBuilder.DropTable(
name: "Leistungsverzeichnisses");
migrationBuilder.DropTable(
name: "Kunden");
}
}
}