//
using System;
using GermanApp.Infrastructure.Data.DbContext;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace GermanApp.Infrastructure.Data.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260613125706_AddStorySegmentAndStoryProgressTables")]
partial class AddStorySegmentAndStoryProgressTables
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GermanApp.Domain.Entities.Lesson", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("Description")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("LevelId")
.HasColumnType("integer");
b.Property("LevelId1")
.HasColumnType("integer");
b.Property("Order")
.HasColumnType("integer");
b.Property("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property("Topic")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LevelId1");
b.HasIndex("LevelId", "Order")
.IsUnique();
b.ToTable("Lessons");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Level", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Code")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("Order")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.HasIndex("Order")
.IsUnique();
b.ToTable("Levels");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Quiz", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("Description")
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("LessonId")
.HasColumnType("integer");
b.Property("PassingScore")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(80);
b.Property("ShuffleQuestions")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("TimeLimitMinutes")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LessonId");
b.ToTable("Quizzes");
});
modelBuilder.Entity("GermanApp.Domain.Entities.QuizOption", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("IsCorrect")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property("Order")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property("QuizQuestionId")
.HasColumnType("integer");
b.Property("Text")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.HasKey("Id");
b.HasIndex("QuizQuestionId", "Order")
.IsUnique();
b.ToTable("QuizOptions");
});
modelBuilder.Entity("GermanApp.Domain.Entities.QuizQuestion", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CorrectAnswer")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("Difficulty")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(3);
b.Property("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("Order")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property("Points")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property("QuestionText")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property("QuizId")
.HasColumnType("integer");
b.Property("Type")
.HasColumnType("integer");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("QuizId", "Order")
.IsUnique();
b.ToTable("QuizQuestions");
});
modelBuilder.Entity("GermanApp.Domain.Entities.RefreshToken", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("RevokedAt")
.HasColumnType("timestamp with time zone");
b.Property("Token")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("GermanApp.Domain.Entities.StoryProgress", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CompletedAt")
.HasColumnType("timestamp with time zone");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("IsCompleted")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property("LevelId")
.HasColumnType("integer");
b.Property("StorySegmentId")
.HasColumnType("integer");
b.Property("UnlockedAt")
.HasColumnType("timestamp with time zone");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property("UserId")
.HasColumnType("integer");
b.Property("UserId1")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("LevelId");
b.HasIndex("StorySegmentId");
b.HasIndex("UserId1");
b.HasIndex("UserId", "StorySegmentId")
.IsUnique();
b.ToTable("StoryProgress");
});
modelBuilder.Entity("GermanApp.Domain.Entities.StorySegment", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("AudioUrl")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property("Content")
.IsRequired()
.HasColumnType("text");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("EstimatedReadingMinutes")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(2);
b.Property("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(true);
b.Property("LessonId")
.HasColumnType("integer");
b.Property("LessonId1")
.HasColumnType("integer");
b.Property("LevelId")
.HasColumnType("integer");
b.Property("LevelId1")
.HasColumnType("integer");
b.Property("Order")
.HasColumnType("integer");
b.Property("Theme")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("LessonId");
b.HasIndex("LessonId1");
b.HasIndex("LevelId1");
b.HasIndex("LevelId", "Order")
.IsUnique();
b.ToTable("StorySegments");
});
modelBuilder.Entity("GermanApp.Domain.Entities.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("CurrentLevel")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(10)
.HasColumnType("character varying(10)")
.HasDefaultValue("A1");
b.Property("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("PasswordHash")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property("Streak")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property("TotalPoints")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("Username")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("GermanApp.Domain.Entities.UserProgress", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("IsCompleted")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false);
b.Property("LastAttemptDate")
.HasColumnType("timestamp with time zone");
b.Property("LessonId")
.HasColumnType("integer");
b.Property("QuizScore")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("LessonId");
b.HasIndex("UserId", "LessonId")
.IsUnique();
b.ToTable("UserProgress");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Lesson", b =>
{
b.HasOne("GermanApp.Domain.Entities.Level", "Level")
.WithMany()
.HasForeignKey("LevelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.Level", null)
.WithMany("Lessons")
.HasForeignKey("LevelId1");
b.Navigation("Level");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Quiz", b =>
{
b.HasOne("GermanApp.Domain.Entities.Lesson", "Lesson")
.WithMany()
.HasForeignKey("LessonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lesson");
});
modelBuilder.Entity("GermanApp.Domain.Entities.QuizOption", b =>
{
b.HasOne("GermanApp.Domain.Entities.QuizQuestion", "QuizQuestion")
.WithMany("Options")
.HasForeignKey("QuizQuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("QuizQuestion");
});
modelBuilder.Entity("GermanApp.Domain.Entities.QuizQuestion", b =>
{
b.HasOne("GermanApp.Domain.Entities.Quiz", "Quiz")
.WithMany("Questions")
.HasForeignKey("QuizId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Quiz");
});
modelBuilder.Entity("GermanApp.Domain.Entities.RefreshToken", b =>
{
b.HasOne("GermanApp.Domain.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("GermanApp.Domain.Entities.StoryProgress", b =>
{
b.HasOne("GermanApp.Domain.Entities.Level", "Level")
.WithMany()
.HasForeignKey("LevelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.StorySegment", "StorySegment")
.WithMany()
.HasForeignKey("StorySegmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.User", null)
.WithMany("StoryProgress")
.HasForeignKey("UserId1");
b.Navigation("Level");
b.Navigation("StorySegment");
b.Navigation("User");
});
modelBuilder.Entity("GermanApp.Domain.Entities.StorySegment", b =>
{
b.HasOne("GermanApp.Domain.Entities.Lesson", "Lesson")
.WithMany()
.HasForeignKey("LessonId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("GermanApp.Domain.Entities.Lesson", null)
.WithMany("StorySegments")
.HasForeignKey("LessonId1");
b.HasOne("GermanApp.Domain.Entities.Level", "Level")
.WithMany()
.HasForeignKey("LevelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.Level", null)
.WithMany("StorySegments")
.HasForeignKey("LevelId1");
b.Navigation("Lesson");
b.Navigation("Level");
});
modelBuilder.Entity("GermanApp.Domain.Entities.UserProgress", b =>
{
b.HasOne("GermanApp.Domain.Entities.Lesson", "Lesson")
.WithMany()
.HasForeignKey("LessonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GermanApp.Domain.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Lesson");
b.Navigation("User");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Lesson", b =>
{
b.Navigation("StorySegments");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Level", b =>
{
b.Navigation("Lessons");
b.Navigation("StorySegments");
});
modelBuilder.Entity("GermanApp.Domain.Entities.Quiz", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("GermanApp.Domain.Entities.QuizQuestion", b =>
{
b.Navigation("Options");
});
modelBuilder.Entity("GermanApp.Domain.Entities.User", b =>
{
b.Navigation("StoryProgress");
});
#pragma warning restore 612, 618
}
}
}