using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace TransportGuideDatabaseImplements.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { 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: "Routes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TransportTypeId = table.Column(type: "integer", nullable: false), Name = table.Column(type: "text", nullable: false), IP = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Routes", x => x.Id); table.ForeignKey( name: "FK_Routes_TransportTypes_TransportTypeId", column: x => x.TransportTypeId, principalTable: "TransportTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "StopRoutes", 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), Nomer = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StopRoutes", x => x.Id); table.ForeignKey( name: "FK_StopRoutes_Routes_RouteId", column: x => x.RouteId, principalTable: "Routes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_StopRoutes_Stops_StopId", column: x => x.StopId, principalTable: "Stops", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Routes_TransportTypeId", table: "Routes", column: "TransportTypeId"); migrationBuilder.CreateIndex( name: "IX_StopRoutes_RouteId", table: "StopRoutes", column: "RouteId"); migrationBuilder.CreateIndex( name: "IX_StopRoutes_StopId", table: "StopRoutes", column: "StopId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "StopRoutes"); migrationBuilder.DropTable( name: "Routes"); migrationBuilder.DropTable( name: "Stops"); migrationBuilder.DropTable( name: "TransportTypes"); } } }