using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace TransportCompanyDatabaseImplement.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Cargos", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CargoName = table.Column(type: "nvarchar(max)", nullable: false), Weight = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Cargos", x => x.Id); }); migrationBuilder.CreateTable( name: "Drivers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DriverFio = table.Column(type: "nvarchar(max)", nullable: false), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Drivers", x => x.Id); }); migrationBuilder.CreateTable( name: "Points", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), PointName = table.Column(type: "nvarchar(max)", nullable: false), Address = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Points", x => x.Id); }); migrationBuilder.CreateTable( name: "Transports", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Model = table.Column(type: "nvarchar(max)", nullable: false), LoadCapacity = table.Column(type: "int", nullable: false), StateNumber = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Transports", x => x.Id); }); migrationBuilder.CreateTable( name: "Transportations", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DriverId = table.Column(type: "int", nullable: false), TransportId = table.Column(type: "int", nullable: false), CargoId = table.Column(type: "int", nullable: false), Count = table.Column(type: "int", nullable: false), PointToId = table.Column(type: "int", nullable: false), PointFromId = table.Column(type: "int", nullable: false), Status = table.Column(type: "int", nullable: false), DepartureDate = table.Column(type: "datetime2", nullable: false), ArrivalDate = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Transportations", x => x.Id); table.ForeignKey( name: "FK_Transportations_Cargos_CargoId", column: x => x.CargoId, principalTable: "Cargos", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Transportations_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Transportations_Points_PointFromId", column: x => x.PointFromId, principalTable: "Points", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Transportations_Points_PointToId", column: x => x.PointToId, principalTable: "Points", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Transportations_Transports_TransportId", column: x => x.TransportId, principalTable: "Transports", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Transportations_CargoId", table: "Transportations", column: "CargoId"); migrationBuilder.CreateIndex( name: "IX_Transportations_DriverId", table: "Transportations", column: "DriverId"); migrationBuilder.CreateIndex( name: "IX_Transportations_PointFromId", table: "Transportations", column: "PointFromId"); migrationBuilder.CreateIndex( name: "IX_Transportations_PointToId", table: "Transportations", column: "PointToId"); migrationBuilder.CreateIndex( name: "IX_Transportations_TransportId", table: "Transportations", column: "TransportId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Transportations"); migrationBuilder.DropTable( name: "Cargos"); migrationBuilder.DropTable( name: "Drivers"); migrationBuilder.DropTable( name: "Points"); migrationBuilder.DropTable( name: "Transports"); } } }