using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace DaSaSo.EntityFramework.Migrations { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("SET TimeZone='UTC'"); 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: true), LastName = table.Column(type: "text", nullable: true), Country = table.Column(type: "text", nullable: true), Street = table.Column(type: "text", nullable: true), Postcode = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Impregnations", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DN = table.Column(type: "integer", nullable: false), Number = table.Column(type: "text", nullable: true), Linerlength = table.Column(type: "numeric", nullable: false), IsAvaible = table.Column(type: "boolean", nullable: false), Date = table.Column(type: "timestamp with time zone", nullable: false), LinerNumber = table.Column(type: "text", nullable: true), WallThickness = table.Column(type: "numeric", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Impregnations", x => x.Id); }); migrationBuilder.CreateTable( name: "SewerPoints", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Objektnummer = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_SewerPoints", 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: true), Projektnummer = table.Column(type: "text", nullable: true), ClientId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Projects", x => x.Id); table.ForeignKey( name: "FK_Projects_Clients_ClientId", column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "PipeLiners", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), InversionPressure = table.Column(type: "numeric", nullable: false), ImpregnationId = table.Column(type: "integer", nullable: true), ClosedEnd = table.Column(type: "boolean", nullable: false), Preliner = table.Column(type: "boolean", nullable: false), TemperaturAssembly = table.Column(type: "numeric", nullable: false), TemperaturStorage = table.Column(type: "numeric", nullable: false), LinerLength = table.Column(type: "numeric", nullable: false), Operator = table.Column(type: "text", nullable: true), Date = table.Column(type: "timestamp with time zone", nullable: false), TemperatureOutdoors = table.Column(type: "numeric", nullable: false), TemperatureSewer = table.Column(type: "numeric", nullable: false), Weather = table.Column(type: "text", nullable: true), PreparationType = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PipeLiners", x => x.Id); table.ForeignKey( name: "FK_PipeLiners_Impregnations_ImpregnationId", column: x => x.ImpregnationId, principalTable: "Impregnations", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Buildingsites", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProjectId = table.Column(type: "integer", nullable: true), BuildingSiteNumber = table.Column(type: "text", nullable: true), Country = table.Column(type: "text", nullable: true), ContactPerson = table.Column(type: "text", 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"); }); 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: true), SanNummer = table.Column(type: "text", nullable: true), StreetName = table.Column(type: "text", nullable: true), Hausnummer = table.Column(type: "text", nullable: true), ObjektName = table.Column(type: "text", nullable: true), PunktObenId = table.Column(type: "integer", nullable: true), PunktObenType = table.Column(type: "integer", nullable: false), PunktUntenId = table.Column(type: "integer", nullable: true), PunktUntenType = table.Column(type: "integer", nullable: false), Material = table.Column(type: "text", nullable: true), DN = table.Column(type: "integer", nullable: false), SewerLength = table.Column(type: "numeric", nullable: false), SewerActivated = table.Column(type: "boolean", nullable: false), SewerCleaned = table.Column(type: "boolean", nullable: false), WaterBarrier = table.Column(type: "boolean", nullable: false), PermitNeeded = table.Column(type: "boolean", nullable: false), BuildingsiteBarier = table.Column(type: "boolean", nullable: false), PipeLinerId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_SewerObjects", x => x.Id); table.ForeignKey( name: "FK_SewerObjects_Buildingsites_BuildingSiteId", column: x => x.BuildingSiteId, principalTable: "Buildingsites", principalColumn: "Id"); table.ForeignKey( name: "FK_SewerObjects_PipeLiners_PipeLinerId", column: x => x.PipeLinerId, principalTable: "PipeLiners", principalColumn: "Id"); table.ForeignKey( name: "FK_SewerObjects_SewerPoints_PunktObenId", column: x => x.PunktObenId, principalTable: "SewerPoints", principalColumn: "Id"); table.ForeignKey( name: "FK_SewerObjects_SewerPoints_PunktUntenId", column: x => x.PunktUntenId, principalTable: "SewerPoints", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "SewerDamages", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), SewerObjectId = table.Column(type: "integer", nullable: true), Distance = table.Column(type: "numeric", nullable: false), DamageType = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SewerDamages", x => x.Id); table.ForeignKey( name: "FK_SewerDamages_SewerObjects_SewerObjectId", column: x => x.SewerObjectId, principalTable: "SewerObjects", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Buildingsites_ProjectId", table: "Buildingsites", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_PipeLiners_ImpregnationId", table: "PipeLiners", column: "ImpregnationId"); migrationBuilder.CreateIndex( name: "IX_Projects_ClientId", table: "Projects", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_SewerDamages_SewerObjectId", table: "SewerDamages", column: "SewerObjectId"); migrationBuilder.CreateIndex( name: "IX_SewerObjects_BuildingSiteId", table: "SewerObjects", column: "BuildingSiteId"); migrationBuilder.CreateIndex( name: "IX_SewerObjects_PipeLinerId", table: "SewerObjects", column: "PipeLinerId"); migrationBuilder.CreateIndex( name: "IX_SewerObjects_PunktObenId", table: "SewerObjects", column: "PunktObenId"); migrationBuilder.CreateIndex( name: "IX_SewerObjects_PunktUntenId", table: "SewerObjects", column: "PunktUntenId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "SewerDamages"); migrationBuilder.DropTable( name: "SewerObjects"); migrationBuilder.DropTable( name: "Buildingsites"); migrationBuilder.DropTable( name: "PipeLiners"); migrationBuilder.DropTable( name: "SewerPoints"); migrationBuilder.DropTable( name: "Projects"); migrationBuilder.DropTable( name: "Impregnations"); migrationBuilder.DropTable( name: "Clients"); } } }