Datenbank umgebaut

This commit is contained in:
Husky
2020-02-16 19:31:30 +01:00
parent 07e9a1c50b
commit 3b01d98d2c
12 changed files with 327 additions and 118 deletions

View File

@@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace KanSan.Migrations
{
[DbContext(typeof(KanSanContext))]
[Migration("20200213193512_InitialCommit")]
[Migration("20200216122731_InitialCommit")]
partial class InitialCommit
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -21,31 +21,34 @@ namespace KanSan.Migrations
.HasAnnotation("ProductVersion", "3.1.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("KanSan.Baustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
{
b.Property<Guid>("BaustelleID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("KundenID")
b.Property<Guid?>("KundeID")
.HasColumnType("uuid");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Projektnummer")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.HasKey("BaustelleID");
b.HasKey("ID");
b.HasIndex("KundenID");
b.HasIndex("KundeID");
b.ToTable("Baustellen");
});
modelBuilder.Entity("KanSan.Kunden", b =>
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
{
b.Property<Guid>("KundenID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
@@ -64,12 +67,26 @@ namespace KanSan.Migrations
b.Property<string>("Vorname")
.HasColumnType("text");
b.HasKey("KundenID");
b.HasKey("ID");
b.ToTable("Kunden");
});
modelBuilder.Entity("KanSan.LeistungsverzeichnisBaustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Beschreibung")
.HasColumnType("text");
b.HasKey("ID");
b.ToTable("Leistungsverzeichnisses");
});
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
{
b.Property<int>("LeistungsverzeichnisBaustelleID")
.ValueGeneratedOnAdd()
@@ -91,9 +108,9 @@ namespace KanSan.Migrations
b.ToTable("LeistungsverzeichnisBaustelle");
});
modelBuilder.Entity("KanSan.Leistungsverzeichniss", b =>
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
{
b.Property<Guid>("LeistungsverzeichnissID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
@@ -109,28 +126,40 @@ namespace KanSan.Migrations
b.Property<decimal>("PositionEinheitspreis")
.HasColumnType("numeric");
b.HasKey("LeistungsverzeichnissID");
b.Property<Guid?>("ref_leistungsverzeichnisID")
.HasColumnType("uuid");
b.ToTable("Leistungsverzeichnisses");
b.HasKey("ID");
b.HasIndex("ref_leistungsverzeichnisID");
b.ToTable("LeistungsverzeichnisPosition");
});
modelBuilder.Entity("KanSan.Baustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
{
b.HasOne("KanSan.Kunden", null)
b.HasOne("KanSan.Klassen.Kunde", null)
.WithMany("Baustellen")
.HasForeignKey("KundenID");
.HasForeignKey("KundeID");
});
modelBuilder.Entity("KanSan.LeistungsverzeichnisBaustelle", b =>
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
{
b.HasOne("KanSan.Baustelle", "Baustelle")
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
.WithMany()
.HasForeignKey("BaustelleID");
b.HasOne("KanSan.Leistungsverzeichniss", "Leistungsverzeichniss")
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
.WithMany()
.HasForeignKey("LeistungsverzeichnissID");
});
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
{
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
.WithMany("Positionen")
.HasForeignKey("ref_leistungsverzeichnisID");
});
#pragma warning restore 612, 618
}
}

View File

@@ -12,7 +12,7 @@ namespace KanSan.Migrations
name: "Kunden",
columns: table => new
{
KundenID = table.Column<Guid>(nullable: false),
ID = table.Column<Guid>(nullable: false),
Vorname = table.Column<string>(nullable: true),
Nachname = table.Column<string>(nullable: true),
Strasse = table.Column<string>(nullable: true),
@@ -21,14 +21,48 @@ namespace KanSan.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_Kunden", x => x.KundenID);
table.PrimaryKey("PK_Kunden", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Leistungsverzeichnisses",
columns: table => new
{
LeistungsverzeichnissID = table.Column<Guid>(nullable: false),
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),
@@ -36,26 +70,12 @@ namespace KanSan.Migrations
},
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.PrimaryKey("PK_LeistungsverzeichnisPosition", x => x.ID);
table.ForeignKey(
name: "FK_Baustellen_Kunden_KundenID",
column: x => x.KundenID,
principalTable: "Kunden",
principalColumn: "KundenID",
name: "FK_LeistungsverzeichnisPosition_Leistungsverzeichnisses_ref_le~",
column: x => x.ref_leistungsverzeichnisID,
principalTable: "Leistungsverzeichnisses",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
});
@@ -75,20 +95,20 @@ namespace KanSan.Migrations
name: "FK_LeistungsverzeichnisBaustelle_Baustellen_BaustelleID",
column: x => x.BaustelleID,
principalTable: "Baustellen",
principalColumn: "BaustelleID",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_LeistungsverzeichnisBaustelle_Leistungsverzeichnisses_Leist~",
column: x => x.LeistungsverzeichnissID,
principalTable: "Leistungsverzeichnisses",
principalColumn: "LeistungsverzeichnissID",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Baustellen_KundenID",
name: "IX_Baustellen_KundeID",
table: "Baustellen",
column: "KundenID");
column: "KundeID");
migrationBuilder.CreateIndex(
name: "IX_LeistungsverzeichnisBaustelle_BaustelleID",
@@ -99,6 +119,11 @@ namespace KanSan.Migrations
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)
@@ -106,6 +131,9 @@ namespace KanSan.Migrations
migrationBuilder.DropTable(
name: "LeistungsverzeichnisBaustelle");
migrationBuilder.DropTable(
name: "LeistungsverzeichnisPosition");
migrationBuilder.DropTable(
name: "Baustellen");

View File

@@ -19,31 +19,34 @@ namespace KanSan.Migrations
.HasAnnotation("ProductVersion", "3.1.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("KanSan.Baustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
{
b.Property<Guid>("BaustelleID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("KundenID")
b.Property<Guid?>("KundeID")
.HasColumnType("uuid");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Projektnummer")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.HasKey("BaustelleID");
b.HasKey("ID");
b.HasIndex("KundenID");
b.HasIndex("KundeID");
b.ToTable("Baustellen");
});
modelBuilder.Entity("KanSan.Kunden", b =>
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
{
b.Property<Guid>("KundenID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
@@ -62,12 +65,26 @@ namespace KanSan.Migrations
b.Property<string>("Vorname")
.HasColumnType("text");
b.HasKey("KundenID");
b.HasKey("ID");
b.ToTable("Kunden");
});
modelBuilder.Entity("KanSan.LeistungsverzeichnisBaustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Beschreibung")
.HasColumnType("text");
b.HasKey("ID");
b.ToTable("Leistungsverzeichnisses");
});
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
{
b.Property<int>("LeistungsverzeichnisBaustelleID")
.ValueGeneratedOnAdd()
@@ -89,9 +106,9 @@ namespace KanSan.Migrations
b.ToTable("LeistungsverzeichnisBaustelle");
});
modelBuilder.Entity("KanSan.Leistungsverzeichniss", b =>
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
{
b.Property<Guid>("LeistungsverzeichnissID")
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
@@ -107,28 +124,40 @@ namespace KanSan.Migrations
b.Property<decimal>("PositionEinheitspreis")
.HasColumnType("numeric");
b.HasKey("LeistungsverzeichnissID");
b.Property<Guid?>("ref_leistungsverzeichnisID")
.HasColumnType("uuid");
b.ToTable("Leistungsverzeichnisses");
b.HasKey("ID");
b.HasIndex("ref_leistungsverzeichnisID");
b.ToTable("LeistungsverzeichnisPosition");
});
modelBuilder.Entity("KanSan.Baustelle", b =>
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
{
b.HasOne("KanSan.Kunden", null)
b.HasOne("KanSan.Klassen.Kunde", null)
.WithMany("Baustellen")
.HasForeignKey("KundenID");
.HasForeignKey("KundeID");
});
modelBuilder.Entity("KanSan.LeistungsverzeichnisBaustelle", b =>
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
{
b.HasOne("KanSan.Baustelle", "Baustelle")
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
.WithMany()
.HasForeignKey("BaustelleID");
b.HasOne("KanSan.Leistungsverzeichniss", "Leistungsverzeichniss")
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
.WithMany()
.HasForeignKey("LeistungsverzeichnissID");
});
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
{
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
.WithMany("Positionen")
.HasForeignKey("ref_leistungsverzeichnisID");
});
#pragma warning restore 612, 618
}
}