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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Firstname = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: false), Country = table.Column(type: "text", nullable: false), Postcode = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Projects", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), ClientId = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BuildingSiteNumber = table.Column(type: "text", nullable: false), Country = table.Column(type: "text", nullable: false), ContactPerson = table.Column(type: "text", nullable: false), ProjectId = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BuildingSiteId = table.Column(type: "integer", nullable: false), StreetName = table.Column(type: "text", nullable: false), ObjektName = table.Column(type: "text", nullable: false), PointFrom = table.Column(type: "text", nullable: false), PointTo = table.Column(type: "text", nullable: false), DN = table.Column(type: "integer", nullable: false), SewerLength = table.Column(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"); } } }