260 lines
12 KiB
C#
260 lines
12 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace SchoolDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class Init : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Executors",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|||
|
Login = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false),
|
|||
|
PhoneNumber = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Executors", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Implementers",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|||
|
Login = table.Column<string>(type: "text", nullable: false),
|
|||
|
Password = table.Column<string>(type: "text", nullable: false),
|
|||
|
PhoneNumber = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Students",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ExecutorId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
Course = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Students", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Students_Executors_ExecutorId",
|
|||
|
column: x => x.ExecutorId,
|
|||
|
principalTable: "Executors",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Requirements",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ExecutorId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
NameOfRequirement = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Requirements", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Requirements_Executors_ExecutorId",
|
|||
|
column: x => x.ExecutorId,
|
|||
|
principalTable: "Executors",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Disciplines",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ImplementerId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|||
|
DateOfReceipt = table.Column<DateOnly>(type: "date", nullable: false),
|
|||
|
DateOfPassage = table.Column<DateOnly>(type: "date", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Disciplines", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Disciplines_Implementers_ImplementerId",
|
|||
|
column: x => x.ImplementerId,
|
|||
|
principalTable: "Implementers",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "StudentsByDisciplines",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
StudentId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DisciplineId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DateOfStudent = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_StudentsByDisciplines", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_StudentsByDisciplines_Students_StudentId",
|
|||
|
column: x => x.ClientId,
|
|||
|
principalTable: "Students",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_StudentsByDisciplines_Disciplines_DisciplineId",
|
|||
|
column: x => x.DisciplineId,
|
|||
|
principalTable: "Disciplines",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "RequirementByDisciplines",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
RequirementId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DisciplineId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_RequirementByDisciplines", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_RequirementByDisciplines_Disciplines_DisciplineId",
|
|||
|
column: x => x.DisciplineId,
|
|||
|
principalTable: "Disciplines",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_RequirementByDisciplines_Requirements_RequirementId",
|
|||
|
column: x => x.RequirementId,
|
|||
|
principalTable: "Requirements",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Accounts",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
StudentByDisciplineId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DateOfAccount = table.Column<DateOnly>(type: "date", nullable: false),
|
|||
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Accounts", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Accounts_StudentsByDisciplines_StudentByDisciplineId",
|
|||
|
column: x => x.StudentByDisciplineId,
|
|||
|
principalTable: "StudentsByDisciplines",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Accounts_StudentByDisciplineId",
|
|||
|
table: "Accounts",
|
|||
|
column: "StudentByDisciplineId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Students_DirectorId",
|
|||
|
table: "Students",
|
|||
|
column: "ExecutorId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_StudentsByDisciplines_StudentId",
|
|||
|
table: "StudentsByDisciplines",
|
|||
|
column: "StudentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_StudentsByDisciplines_DisciplineId",
|
|||
|
table: "StudentsByDisciplines",
|
|||
|
column: "DisciplineId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Disciplines_ImplementerId",
|
|||
|
table: "Disciplines",
|
|||
|
column: "ImplementerId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_RequirementByDisciplines_DisciplineId",
|
|||
|
table: "RequirementByDisciplines",
|
|||
|
column: "DisciplineId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_RequirementByDisciplines_RequirementId",
|
|||
|
table: "RequirementByDisciplines",
|
|||
|
column: "RequirementId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Requirements_ExecutorId",
|
|||
|
table: "Requirements",
|
|||
|
column: "ExecutorId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Accounts");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "RequirementByDisciplines");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "StudentsByDisciplines");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Requirements");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Students");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Disciplines");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Executors");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Implementers");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|