100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace Demo1.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class create : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Presence",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
PresenceId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
ClassDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
LessonNumber = table.Column<int>(type: "integer", nullable: false),
|
|||
|
WasPresent = table.Column<bool>(type: "boolean", nullable: false),
|
|||
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Presence", x => x.PresenceId);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "User",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = 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.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "UserDAO",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
UserId = 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_UserDAO", x => x.UserId);
|
|||
|
});
|
|||
|
|
|||
|
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),
|
|||
|
UserId = table.Column<Guid>(type: "uuid", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Group", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Group_UserDAO_UserId",
|
|||
|
column: x => x.UserId,
|
|||
|
principalTable: "UserDAO",
|
|||
|
principalColumn: "UserId",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Group_UserId",
|
|||
|
table: "Group",
|
|||
|
column: "UserId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Group");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Presence");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "User");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "UserDAO");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|