60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace SurveyBackend.Infrastructure.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Updateanswers : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropPrimaryKey(
|
|
name: "PK_Answers",
|
|
table: "Answers");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Id",
|
|
table: "Answers",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0)
|
|
.Annotation("Sqlite:Autoincrement", true);
|
|
|
|
migrationBuilder.Sql(@"UPDATE ""Answers"" SET ""Id"" = rowid;");
|
|
|
|
migrationBuilder.AddPrimaryKey(
|
|
name: "PK_Answers",
|
|
table: "Answers",
|
|
column: "Id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Answers_CompletionId_QuestionId_AnswerText",
|
|
table: "Answers",
|
|
columns: new[] { "CompletionId", "QuestionId", "AnswerText" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropPrimaryKey(
|
|
name: "PK_Answers",
|
|
table: "Answers");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Answers_CompletionId_QuestionId_AnswerText",
|
|
table: "Answers");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Id",
|
|
table: "Answers");
|
|
|
|
migrationBuilder.AddPrimaryKey(
|
|
name: "PK_Answers",
|
|
table: "Answers",
|
|
columns: new[] { "CompletionId", "QuestionId" });
|
|
}
|
|
}
|
|
}
|