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(nullable: false), Vorname = table.Column(nullable: true), Nachname = table.Column(nullable: true), Strasse = table.Column(nullable: true), PLZ = table.Column(nullable: true), Ort = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Kunden", x => x.ID); }); migrationBuilder.CreateTable( name: "Leistungsverzeichnisses", columns: table => new { ID = table.Column(nullable: false), Beschreibung = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Leistungsverzeichnisses", x => x.ID); }); migrationBuilder.CreateTable( name: "Baustellen", columns: table => new { ID = table.Column(nullable: false), Ort = table.Column(nullable: true), Strasse = table.Column(nullable: true), Projektnummer = table.Column(nullable: true), KundeID = table.Column(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(nullable: false), ref_leistungsverzeichnisID = table.Column(nullable: true), Position = table.Column(nullable: true), PositionBeschreibung = table.Column(nullable: true), PositionEinheit = table.Column(nullable: true), PositionEinheitspreis = table.Column(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(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BaustelleID = table.Column(nullable: true), LeistungsverzeichnissID = table.Column(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"); } } }