93 lines
3.4 KiB
C#
93 lines
3.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Group",
|
|
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_Group", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "User",
|
|
columns: table => new
|
|
{
|
|
Guid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
FIO = table.Column<string>(type: "text", nullable: false),
|
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_User", x => x.Guid);
|
|
table.ForeignKey(
|
|
name: "FK_User_Group_GroupId",
|
|
column: x => x.GroupId,
|
|
principalTable: "Group",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Presence",
|
|
columns: table => new
|
|
{
|
|
UserGuid = table.Column<Guid>(type: "uuid", 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),
|
|
UserDaoGuid = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Presence", x => new { x.UserGuid, x.IsAttedance, x.Date, x.LessonNumber });
|
|
table.ForeignKey(
|
|
name: "FK_Presence_User_UserDaoGuid",
|
|
column: x => x.UserDaoGuid,
|
|
principalTable: "User",
|
|
principalColumn: "Guid",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Presence_UserDaoGuid",
|
|
table: "Presence",
|
|
column: "UserDaoGuid");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_User_GroupId",
|
|
table: "User",
|
|
column: "GroupId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Presence");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "User");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Group");
|
|
}
|
|
}
|
|
}
|