142 lines
5.5 KiB
C#
142 lines
5.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ServiceStationsDataBaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Clients",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Executors",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Executors", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tasks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tasks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Works",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
|
ExecutorId = table.Column<int>(type: "int", nullable: false),
|
|
TaskId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Works", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Works_Executors_ExecutorId",
|
|
column: x => x.ExecutorId,
|
|
principalTable: "Executors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "WorksClients",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
WorkId = table.Column<int>(type: "int", nullable: false),
|
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
|
PointCount = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WorksClients", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_WorksClients_Clients_ClientId",
|
|
column: x => x.ClientId,
|
|
principalTable: "Clients",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_WorksClients_Works_WorkId",
|
|
column: x => x.WorkId,
|
|
principalTable: "Works",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Works_ExecutorId",
|
|
table: "Works",
|
|
column: "ExecutorId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WorksClients_ClientId",
|
|
table: "WorksClients",
|
|
column: "ClientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WorksClients_WorkId",
|
|
table: "WorksClients",
|
|
column: "WorkId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Tasks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "WorksClients");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Clients");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Works");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Executors");
|
|
}
|
|
}
|
|
}
|