using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Demo1.Migrations
{
///
public partial class create : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Presence",
columns: table => new
{
PresenceId = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClassDate = table.Column(type: "timestamp with time zone", nullable: false),
LessonNumber = table.Column(type: "integer", nullable: false),
WasPresent = table.Column(type: "boolean", nullable: false),
UserId = table.Column(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Presence", x => x.PresenceId);
});
migrationBuilder.CreateTable(
name: "User",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
FIO = table.Column(type: "text", nullable: false),
GroupID = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserDAO",
columns: table => new
{
UserId = table.Column(type: "uuid", nullable: false),
FIO = table.Column(type: "text", nullable: false),
GroupID = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserDAO", x => x.UserId);
});
migrationBuilder.CreateTable(
name: "Group",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
UserId = table.Column(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");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Group");
migrationBuilder.DropTable(
name: "Presence");
migrationBuilder.DropTable(
name: "User");
migrationBuilder.DropTable(
name: "UserDAO");
}
}
}