108 lines
4.1 KiB
C#
108 lines
4.1 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class SurveyModelsAdded : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Questionnaires",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Questionnaires", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "QuestionTypeEntities",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Type = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_QuestionTypeEntities", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Questions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
Type = table.Column<int>(type: "int", nullable: false),
|
|
QuestionnaireId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Questions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Questions_Questionnaires_QuestionnaireId",
|
|
column: x => x.QuestionnaireId,
|
|
principalTable: "Questionnaires",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Answers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
QuestionId = table.Column<int>(type: "int", 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.CreateIndex(
|
|
name: "IX_Answers_QuestionId",
|
|
table: "Answers",
|
|
column: "QuestionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Questions_QuestionnaireId",
|
|
table: "Questions",
|
|
column: "QuestionnaireId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Answers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "QuestionTypeEntities");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Questions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Questionnaires");
|
|
}
|
|
}
|
|
}
|