Demo/Migrations/20241028031712_InitialCreate.cs

93 lines
3.4 KiB
C#
Raw Permalink Normal View History

2024-10-24 20:41:31 +00:00
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
{
2024-10-28 03:24:11 +00:00
ID = table.Column<int>(type: "integer", nullable: false)
2024-10-24 20:41:31 +00:00
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
2024-10-28 03:24:11 +00:00
table.PrimaryKey("PK_Groups", x => x.ID);
2024-10-24 20:41:31 +00:00
});
migrationBuilder.CreateTable(
name: "Users",
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_Users", x => x.Guid);
table.ForeignKey(
name: "FK_Users_Groups_GroupID",
column: x => x.GroupID,
principalTable: "Groups",
2024-10-28 03:24:11 +00:00
principalColumn: "ID",
2024-10-24 20:41:31 +00:00
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PresenceDaos",
columns: table => new
{
UserGuid = table.Column<Guid>(type: "uuid", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
LessonNumber = table.Column<int>(type: "integer", nullable: false),
2024-10-28 03:24:11 +00:00
IsAttedance = table.Column<bool>(type: "boolean", nullable: false),
userDAOGuid = table.Column<Guid>(type: "uuid", nullable: false)
2024-10-24 20:41:31 +00:00
},
constraints: table =>
{
2024-10-28 03:24:11 +00:00
table.PrimaryKey("PK_PresenceDaos", x => new { x.UserGuid, x.Date, x.LessonNumber });
2024-10-24 20:41:31 +00:00
table.ForeignKey(
2024-10-28 03:24:11 +00:00
name: "FK_PresenceDaos_Users_userDAOGuid",
column: x => x.userDAOGuid,
2024-10-24 20:41:31 +00:00
principalTable: "Users",
principalColumn: "Guid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
2024-10-28 03:24:11 +00:00
name: "IX_PresenceDaos_userDAOGuid",
2024-10-24 20:41:31 +00:00
table: "PresenceDaos",
2024-10-28 03:24:11 +00:00
column: "userDAOGuid");
2024-10-24 20:41:31 +00:00
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");
}
}
}