148 lines
6.2 KiB
C#
148 lines
6.2 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
|
|
{
|
|
ID = 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.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Leistungsverzeichnisses",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<Guid>(nullable: false),
|
|
Beschreibung = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Leistungsverzeichnisses", x => x.ID);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Baustellen",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<Guid>(nullable: false),
|
|
Ort = table.Column<string>(nullable: true),
|
|
Strasse = table.Column<string>(nullable: true),
|
|
Projektnummer = table.Column<string>(nullable: true),
|
|
KundeID = table.Column<Guid>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Baustellen", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_Baustellen_Kunden_KundeID",
|
|
column: x => x.KundeID,
|
|
principalTable: "Kunden",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LeistungsverzeichnisPosition",
|
|
columns: table => new
|
|
{
|
|
ID = table.Column<Guid>(nullable: false),
|
|
ref_leistungsverzeichnisID = table.Column<Guid>(nullable: true),
|
|
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_LeistungsverzeichnisPosition", x => x.ID);
|
|
table.ForeignKey(
|
|
name: "FK_LeistungsverzeichnisPosition_Leistungsverzeichnisses_ref_le~",
|
|
column: x => x.ref_leistungsverzeichnisID,
|
|
principalTable: "Leistungsverzeichnisses",
|
|
principalColumn: "ID",
|
|
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: "ID",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_LeistungsverzeichnisBaustelle_Leistungsverzeichnisses_Leist~",
|
|
column: x => x.LeistungsverzeichnissID,
|
|
principalTable: "Leistungsverzeichnisses",
|
|
principalColumn: "ID",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Baustellen_KundeID",
|
|
table: "Baustellen",
|
|
column: "KundeID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LeistungsverzeichnisBaustelle_BaustelleID",
|
|
table: "LeistungsverzeichnisBaustelle",
|
|
column: "BaustelleID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LeistungsverzeichnisBaustelle_LeistungsverzeichnissID",
|
|
table: "LeistungsverzeichnisBaustelle",
|
|
column: "LeistungsverzeichnissID");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LeistungsverzeichnisPosition_ref_leistungsverzeichnisID",
|
|
table: "LeistungsverzeichnisPosition",
|
|
column: "ref_leistungsverzeichnisID");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "LeistungsverzeichnisBaustelle");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LeistungsverzeichnisPosition");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Baustellen");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Leistungsverzeichnisses");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Kunden");
|
|
}
|
|
}
|
|
}
|