2024-10-25 09:41:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace Demo.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
2024-11-01 09:42:31 +00:00
|
|
|
|
public partial class InitialMigration : Migration
|
2024-10-25 09:41:35 +00:00
|
|
|
|
{
|
|
|
|
|
/// <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(
|
2024-11-01 09:42:31 +00:00
|
|
|
|
name: "PresenceDaos",
|
2024-10-25 09:41:35 +00:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
2024-11-01 09:42:31 +00:00
|
|
|
|
PresenceId = table.Column<int>(type: "integer", nullable: false)
|
2024-10-25 09:41:35 +00:00
|
|
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
2024-11-01 09:42:31 +00:00
|
|
|
|
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),
|
2024-10-25 09:41:35 +00:00
|
|
|
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-11-01 09:42:31 +00:00
|
|
|
|
table.PrimaryKey("PK_PresenceDaos", x => x.PresenceId);
|
2024-10-25 09:41:35 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2024-11-01 09:42:31 +00:00
|
|
|
|
name: "Users",
|
2024-10-25 09:41:35 +00:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
2024-11-01 09:42:31 +00:00
|
|
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
|
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
|
|
|
FIO = table.Column<string>(type: "text", nullable: false),
|
2024-10-25 09:41:35 +00:00
|
|
|
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2024-11-01 09:42:31 +00:00
|
|
|
|
table.PrimaryKey("PK_Users", x => x.UserId);
|
2024-10-25 09:41:35 +00:00
|
|
|
|
table.ForeignKey(
|
2024-11-01 09:42:31 +00:00
|
|
|
|
name: "FK_Users_Groups_GroupId",
|
|
|
|
|
column: x => x.GroupId,
|
|
|
|
|
principalTable: "Groups",
|
|
|
|
|
principalColumn: "Id",
|
2024-10-25 09:41:35 +00:00
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|