using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace RouteGuideDatabaseImplements.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Routes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Routes", x => x.Id); }); migrationBuilder.CreateTable( name: "Stops", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Stops", x => x.Id); }); migrationBuilder.CreateTable( name: "TransportTypes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Price = table.Column(type: "double precision", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TransportTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "RoutesStops", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), StopId = table.Column(type: "integer", nullable: false), RouteId = table.Column(type: "integer", nullable: false), Number = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RoutesStops", x => x.Id); table.ForeignKey( name: "FK_RoutesStops_Routes_RouteId", column: x => x.RouteId, principalTable: "Routes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_RoutesStops_Stops_StopId", column: x => x.StopId, principalTable: "Stops", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Transports", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DriverName = table.Column(type: "text", nullable: false), RouteId = table.Column(type: "integer", nullable: false), TransportTypeId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Transports", x => x.Id); table.ForeignKey( name: "FK_Transports_TransportTypes_TransportTypeId", column: x => x.TransportTypeId, principalTable: "TransportTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_RoutesStops_RouteId", table: "RoutesStops", column: "RouteId"); migrationBuilder.CreateIndex( name: "IX_RoutesStops_StopId", table: "RoutesStops", column: "StopId"); migrationBuilder.CreateIndex( name: "IX_Transports_TransportTypeId", table: "Transports", column: "TransportTypeId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "RoutesStops"); migrationBuilder.DropTable( name: "Transports"); migrationBuilder.DropTable( name: "Routes"); migrationBuilder.DropTable( name: "Stops"); migrationBuilder.DropTable( name: "TransportTypes"); } } }