add migrations for new models
This commit is contained in:
parent
e8d9895795
commit
3bc2181e68
2 changed files with 81 additions and 29 deletions
|
|
@ -0,0 +1,78 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SurveyBackend.Infrastructure.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Changingquestionslogic : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_SingleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_AnswerVariant_MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_AnswerVariant_SingleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SingleAnswerQuestionId",
|
||||
table: "AnswerVariant");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "SingleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AnswerVariant_MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
column: "MultipleAnswerQuestionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AnswerVariant_SingleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
column: "SingleAnswerQuestionId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_MultipleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
column: "MultipleAnswerQuestionId",
|
||||
principalTable: "Questions",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_SingleAnswerQuestionId",
|
||||
table: "AnswerVariant",
|
||||
column: "SingleAnswerQuestionId",
|
||||
principalTable: "Questions",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,27 +99,17 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("MultipleAnswerQuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("SingleAnswerQuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MultipleAnswerQuestionId");
|
||||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.HasIndex("SingleAnswerQuestionId");
|
||||
|
||||
b.ToTable("AnswerVariant");
|
||||
});
|
||||
|
||||
|
|
@ -252,20 +242,12 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.AnswerVariant", b =>
|
||||
{
|
||||
b.HasOne("SurveyLib.Core.Models.QuestionVariants.MultipleAnswerQuestion", null)
|
||||
.WithMany("AnswerVariants")
|
||||
.HasForeignKey("MultipleAnswerQuestionId");
|
||||
|
||||
b.HasOne("SurveyLib.Core.Models.QuestionBase", "Question")
|
||||
.WithMany()
|
||||
.WithMany("AnswerVariants")
|
||||
.HasForeignKey("QuestionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SurveyLib.Core.Models.QuestionVariants.SingleAnswerQuestion", null)
|
||||
.WithMany("AnswerVariants")
|
||||
.HasForeignKey("SingleAnswerQuestionId");
|
||||
|
||||
b.Navigation("Question");
|
||||
});
|
||||
|
||||
|
|
@ -306,6 +288,8 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionBase", b =>
|
||||
{
|
||||
b.Navigation("AnswerVariants");
|
||||
|
||||
b.Navigation("Answers");
|
||||
});
|
||||
|
||||
|
|
@ -315,16 +299,6 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
|
||||
b.Navigation("Questions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionVariants.MultipleAnswerQuestion", b =>
|
||||
{
|
||||
b.Navigation("AnswerVariants");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionVariants.SingleAnswerQuestion", b =>
|
||||
{
|
||||
b.Navigation("AnswerVariants");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue