95 lines
3.7 KiB
C#
95 lines
3.7 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace Demo.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitialCreate : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Groups",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Groups", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Users",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FIO = table.Column<string>(type: "text", nullable: false),
|
|||
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Users", x => x.UserId);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Users_Groups_GroupId",
|
|||
|
column: x => x.GroupId,
|
|||
|
principalTable: "Groups",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "PresenceDaos",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
IsAttedance = table.Column<bool>(type: "boolean", nullable: false),
|
|||
|
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
|||
|
LessonNumber = table.Column<int>(type: "integer", nullable: false),
|
|||
|
UserDaoUserId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_PresenceDaos", x => new { x.UserId, x.Date, x.IsAttedance, x.LessonNumber });
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_PresenceDaos_Users_UserDaoUserId",
|
|||
|
column: x => x.UserDaoUserId,
|
|||
|
principalTable: "Users",
|
|||
|
principalColumn: "UserId",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_PresenceDaos_UserDaoUserId",
|
|||
|
table: "PresenceDaos",
|
|||
|
column: "UserDaoUserId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Users_GroupId",
|
|||
|
table: "Users",
|
|||
|
column: "GroupId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "PresenceDaos");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Users");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Groups");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|