168 lines
6.9 KiB
C#
168 lines
6.9 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace TransportCompanyDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitialCreate : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Cargos",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
CargoName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Weight = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Cargos", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Drivers",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
DriverFio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Drivers", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Points",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
PointName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Address = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Points", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Transports",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
Model = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
LoadCapacity = table.Column<int>(type: "int", nullable: false),
|
|||
|
StateNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Transports", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Transportations",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
DriverId = table.Column<int>(type: "int", nullable: false),
|
|||
|
TransportId = table.Column<int>(type: "int", nullable: false),
|
|||
|
CargoId = table.Column<int>(type: "int", nullable: false),
|
|||
|
Count = table.Column<int>(type: "int", nullable: false),
|
|||
|
PointToId = table.Column<int>(type: "int", nullable: false),
|
|||
|
PointFromId = table.Column<int>(type: "int", nullable: false),
|
|||
|
Status = table.Column<int>(type: "int", nullable: false),
|
|||
|
DepartureDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|||
|
ArrivalDate = table.Column<DateTime>(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");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
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");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|