add migrations
This commit is contained in:
parent
6898590cec
commit
f61cbac32a
3 changed files with 405 additions and 1 deletions
|
|
@ -0,0 +1,311 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using SurveyBackend.Infrastructure.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SurveyBackend.Infrastructure.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20250520111858_Add CreatedAt to survey")]
|
||||
partial class AddCreatedAttosurvey
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.15");
|
||||
|
||||
modelBuilder.Entity("GroupUser", b =>
|
||||
{
|
||||
b.Property<int>("GroupsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("UsersId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("GroupsId", "UsersId");
|
||||
|
||||
b.HasIndex("UsersId");
|
||||
|
||||
b.ToTable("GroupUser");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyBackend.Core.Models.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyBackend.Core.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Answer", b =>
|
||||
{
|
||||
b.Property<int>("CompletionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AnswerText")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CompletionId", "QuestionId");
|
||||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.ToTable("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.AnswerVariant", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("QuestionId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.ToTable("AnswerVariants");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Completion", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("FinishedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SurveyId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SurveyId");
|
||||
|
||||
b.ToTable("Completions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionBase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Discriminator")
|
||||
.IsRequired()
|
||||
.HasMaxLength(34)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SurveyId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SurveyId");
|
||||
|
||||
b.ToTable("Questions");
|
||||
|
||||
b.HasDiscriminator().HasValue("QuestionBase");
|
||||
|
||||
b.UseTphMappingStrategy();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Survey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreatedBy");
|
||||
|
||||
b.ToTable("Surveys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionVariants.MultipleAnswerQuestion", b =>
|
||||
{
|
||||
b.HasBaseType("SurveyLib.Core.Models.QuestionBase");
|
||||
|
||||
b.HasDiscriminator().HasValue("MultipleAnswerQuestion");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionVariants.SingleAnswerQuestion", b =>
|
||||
{
|
||||
b.HasBaseType("SurveyLib.Core.Models.QuestionBase");
|
||||
|
||||
b.HasDiscriminator().HasValue("SingleAnswerQuestion");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionVariants.TextQuestion", b =>
|
||||
{
|
||||
b.HasBaseType("SurveyLib.Core.Models.QuestionBase");
|
||||
|
||||
b.HasDiscriminator().HasValue("TextQuestion");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GroupUser", b =>
|
||||
{
|
||||
b.HasOne("SurveyBackend.Core.Models.Group", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GroupsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SurveyBackend.Core.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UsersId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Answer", b =>
|
||||
{
|
||||
b.HasOne("SurveyLib.Core.Models.Completion", "Completion")
|
||||
.WithMany("Answers")
|
||||
.HasForeignKey("CompletionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SurveyLib.Core.Models.QuestionBase", "Question")
|
||||
.WithMany("Answers")
|
||||
.HasForeignKey("QuestionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Completion");
|
||||
|
||||
b.Navigation("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.AnswerVariant", b =>
|
||||
{
|
||||
b.HasOne("SurveyLib.Core.Models.QuestionBase", "Question")
|
||||
.WithMany("AnswerVariants")
|
||||
.HasForeignKey("QuestionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Question");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Completion", b =>
|
||||
{
|
||||
b.HasOne("SurveyLib.Core.Models.Survey", "Survey")
|
||||
.WithMany("Completions")
|
||||
.HasForeignKey("SurveyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Survey");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionBase", b =>
|
||||
{
|
||||
b.HasOne("SurveyLib.Core.Models.Survey", "Survey")
|
||||
.WithMany("Questions")
|
||||
.HasForeignKey("SurveyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Survey");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Survey", b =>
|
||||
{
|
||||
b.HasOne("SurveyBackend.Core.Models.User", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedBy")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Completion", b =>
|
||||
{
|
||||
b.Navigation("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.QuestionBase", b =>
|
||||
{
|
||||
b.Navigation("AnswerVariants");
|
||||
|
||||
b.Navigation("Answers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Survey", b =>
|
||||
{
|
||||
b.Navigation("Completions");
|
||||
|
||||
b.Navigation("Questions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SurveyBackend.Infrastructure.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddCreatedAttosurvey : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_QuestionId",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_AnswerVariant",
|
||||
table: "AnswerVariant");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "AnswerVariant",
|
||||
newName: "AnswerVariants");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_AnswerVariant_QuestionId",
|
||||
table: "AnswerVariants",
|
||||
newName: "IX_AnswerVariants_QuestionId");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Surveys",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_AnswerVariants",
|
||||
table: "AnswerVariants",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_AnswerVariants_Questions_QuestionId",
|
||||
table: "AnswerVariants",
|
||||
column: "QuestionId",
|
||||
principalTable: "Questions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_AnswerVariants_Questions_QuestionId",
|
||||
table: "AnswerVariants");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_AnswerVariants",
|
||||
table: "AnswerVariants");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Surveys");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "AnswerVariants",
|
||||
newName: "AnswerVariant");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_AnswerVariants_QuestionId",
|
||||
table: "AnswerVariant",
|
||||
newName: "IX_AnswerVariant_QuestionId");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_AnswerVariant",
|
||||
table: "AnswerVariant",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_AnswerVariant_Questions_QuestionId",
|
||||
table: "AnswerVariant",
|
||||
column: "QuestionId",
|
||||
principalTable: "Questions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
|
||||
b.HasIndex("QuestionId");
|
||||
|
||||
b.ToTable("AnswerVariant");
|
||||
b.ToTable("AnswerVariants");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SurveyLib.Core.Models.Completion", b =>
|
||||
|
|
@ -167,6 +167,9 @@ namespace SurveyBackend.Infrastructure.Data.Migrations
|
|||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("CreatedBy")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue