196 lines
8.8 KiB
C#
196 lines
8.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace KTUSAPS.Data.Migrations
|
|
{
|
|
public partial class Initial : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Admins",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Comment = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Admins", x => x.UserId);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Issues",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
UserID = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Email = table.Column<string>(type: "varchar(320)", maxLength: 320, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Publishable = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
Solved = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Description = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Issues", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Solutions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
SolutionLt = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SolutionEn = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Solutions", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PublishedFeedbacks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
FeedbackLt = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FeedbackEn = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IssueId = table.Column<int>(type: "int", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PublishedFeedbacks", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PublishedFeedbacks_Issues_IssueId",
|
|
column: x => x.IssueId,
|
|
principalTable: "Issues",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PublishedProblems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
ProblemLt = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProblemEn = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ResponseLt = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ResponseEn = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IssueId = table.Column<int>(type: "int", nullable: true),
|
|
SolutionId = table.Column<int>(type: "int", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PublishedProblems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PublishedProblems_Issues_IssueId",
|
|
column: x => x.IssueId,
|
|
principalTable: "Issues",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_PublishedProblems_Solutions_SolutionId",
|
|
column: x => x.SolutionId,
|
|
principalTable: "Solutions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Votes",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ProblemId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Votes", x => new { x.UserId, x.ProblemId });
|
|
table.ForeignKey(
|
|
name: "FK_Votes_PublishedProblems_ProblemId",
|
|
column: x => x.ProblemId,
|
|
principalTable: "PublishedProblems",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PublishedFeedbacks_IssueId",
|
|
table: "PublishedFeedbacks",
|
|
column: "IssueId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PublishedProblems_IssueId",
|
|
table: "PublishedProblems",
|
|
column: "IssueId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PublishedProblems_SolutionId",
|
|
table: "PublishedProblems",
|
|
column: "SolutionId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Votes_ProblemId",
|
|
table: "Votes",
|
|
column: "ProblemId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Admins");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PublishedFeedbacks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Votes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PublishedProblems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Issues");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Solutions");
|
|
}
|
|
}
|
|
}
|