Files
Multiplechoicetrainer/MultipleChoiceTrainer/Data/Migrations/20200604185621_BusinessEntities.cs
2020-06-04 22:45:42 +02:00

147 lines
5.5 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace MultipleChoiceTrainer.Data.Migrations
{
public partial class BusinessEntities : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sections",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
CategoryId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sections", x => x.Id);
table.ForeignKey(
name: "FK_Sections_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Questions",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(nullable: true),
SectionId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Questions", x => x.Id);
table.ForeignKey(
name: "FK_Questions_Sections_SectionId",
column: x => x.SectionId,
principalTable: "Sections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Answers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Date = table.Column<DateTime>(nullable: false),
QuestionId = table.Column<int>(nullable: false),
Successfull = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Answers", x => x.Id);
table.ForeignKey(
name: "FK_Answers_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Choices",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuestionId = table.Column<int>(nullable: false),
Text = table.Column<string>(nullable: true),
IsTrue = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Choices", x => x.Id);
table.ForeignKey(
name: "FK_Choices_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answers_QuestionId",
table: "Answers",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Choices_QuestionId",
table: "Choices",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Questions_SectionId",
table: "Questions",
column: "SectionId");
migrationBuilder.CreateIndex(
name: "IX_Sections_CategoryId",
table: "Sections",
column: "CategoryId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Answers");
migrationBuilder.DropTable(
name: "Choices");
migrationBuilder.DropTable(
name: "Questions");
migrationBuilder.DropTable(
name: "Sections");
migrationBuilder.DropTable(
name: "Categories");
}
}
}