Models hinzugefügt

This commit is contained in:
HuskyTeufel
2021-09-12 20:05:24 +02:00
parent 798870879a
commit 18d552a228
13 changed files with 917 additions and 4 deletions

View File

@@ -0,0 +1,124 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DaSaSo.EntityFramework.Migrations
{
public partial class InitialCommit : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Firstname = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false),
Country = table.Column<string>(type: "text", nullable: false),
Postcode = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Projects",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Projects", x => x.Id);
table.ForeignKey(
name: "FK_Projects_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Buildingsites",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BuildingSiteNumber = table.Column<string>(type: "text", nullable: false),
Country = table.Column<string>(type: "text", nullable: false),
ContactPerson = table.Column<string>(type: "text", nullable: false),
ProjectId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Buildingsites", x => x.Id);
table.ForeignKey(
name: "FK_Buildingsites_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SewerObjects",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
BuildingSiteId = table.Column<int>(type: "integer", nullable: false),
StreetName = table.Column<string>(type: "text", nullable: false),
ObjektName = table.Column<string>(type: "text", nullable: false),
PointFrom = table.Column<string>(type: "text", nullable: false),
PointTo = table.Column<string>(type: "text", nullable: false),
DN = table.Column<int>(type: "integer", nullable: false),
SewerLength = table.Column<decimal>(type: "numeric", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SewerObjects", x => x.Id);
table.ForeignKey(
name: "FK_SewerObjects_Buildingsites_BuildingSiteId",
column: x => x.BuildingSiteId,
principalTable: "Buildingsites",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Buildingsites_ProjectId",
table: "Buildingsites",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_Projects_ClientId",
table: "Projects",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_SewerObjects_BuildingSiteId",
table: "SewerObjects",
column: "BuildingSiteId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SewerObjects");
migrationBuilder.DropTable(
name: "Buildingsites");
migrationBuilder.DropTable(
name: "Projects");
migrationBuilder.DropTable(
name: "Clients");
}
}
}