diff --git a/RikiPath.Application/Common/LearningPathTestFixture.cs b/RikiPath.Application/Common/LearningPathTestFixture.cs new file mode 100644 index 0000000..a166752 --- /dev/null +++ b/RikiPath.Application/Common/LearningPathTestFixture.cs @@ -0,0 +1,14 @@ +namespace RikiPath.Application.Common; + +/// +/// Marks learning paths written by the deterministic M4E2E test stub (no AI model involved). +/// Such rows are only valid in a disposable test database; the API flags them so they are never +/// presented to a learner as a real AI recommendation. +/// +public static class LearningPathTestFixture +{ + public const string SummaryMarker = "[M4E2E TEST STUB — NOT REAL AI OUTPUT]"; + + public static bool IsTestFixture(string? summary) + => summary?.StartsWith(SummaryMarker, StringComparison.Ordinal) == true; +} diff --git a/RikiPath.Application/Responses/LearningPaths/LearningPathGenerationStatusResponse.cs b/RikiPath.Application/Responses/LearningPaths/LearningPathGenerationStatusResponse.cs new file mode 100644 index 0000000..b00bccd --- /dev/null +++ b/RikiPath.Application/Responses/LearningPaths/LearningPathGenerationStatusResponse.cs @@ -0,0 +1,65 @@ +namespace RikiPath.Application.Responses.LearningPaths +{ + /// + /// Real server-side state of the learner's latest AI learning-path generation. + /// Every field reflects work the server has actually done; nothing is simulated. + /// The state lives in this API process only: a server restart resets it to "idle". + /// + public class LearningPathGenerationStatusResponse + { + /// idle | running | succeeded | failed + public string State { get; set; } = LearningPathGenerationStates.Idle; + + /// generate (first ACTIVE path) | preview (DRAFT for a level change). + public string? Kind { get; set; } + + /// preparing | analyzing | designing | saving — the step the server is executing now. + public string? Stage { get; set; } + + /// Number of 30-day AI batches already accepted. + public int? CompletedBatches { get; set; } + + /// Total number of 30-day AI batches the plan needs (known once the plan length is computed). + public int? TotalBatches { get; set; } + + public int? PlanDurationDays { get; set; } + + /// + /// True when the work keeps running on the server if the learner leaves the page + /// (generate). False when closing the request cancels it (preview). + /// + public bool ContinuesWhenClientLeaves { get; set; } + + public DateTime? StartedAt { get; set; } + public DateTime? UpdatedAt { get; set; } + public DateTime? FinishedAt { get; set; } + + /// Saved path id when State = succeeded. + public int? PathId { get; set; } + + public string? ErrorCode { get; set; } + public string? ErrorMessage { get; set; } + + /// + /// True only when the server confirmed no AI credit was consumed by this failed run + /// (credit was never reserved, or the reservation was refunded). Null when unknown. + /// + public bool? CreditsPreserved { get; set; } + } + + public static class LearningPathGenerationStates + { + public const string Idle = "idle"; + public const string Running = "running"; + public const string Succeeded = "succeeded"; + public const string Failed = "failed"; + } + + public static class LearningPathGenerationStages + { + public const string Preparing = "preparing"; + public const string Analyzing = "analyzing"; + public const string Designing = "designing"; + public const string Saving = "saving"; + } +} diff --git a/RikiPath.Application/Responses/LearningPaths/LearningPathResponse.cs b/RikiPath.Application/Responses/LearningPaths/LearningPathResponse.cs index 4abdab5..a5227f3 100644 --- a/RikiPath.Application/Responses/LearningPaths/LearningPathResponse.cs +++ b/RikiPath.Application/Responses/LearningPaths/LearningPathResponse.cs @@ -61,6 +61,9 @@ public class LearningPathResponse public DateTime? SuggestedExamDate { get; set; } public List FocusTopics { get; set; } = new(); + + /// true = lộ trình do stub kiểm thử M4E2E sinh ra, không phải đề xuất AI thật. + public bool IsTestFixture { get; set; } public List DailySchedules { get; set; } = new(); } } diff --git a/RikiPath.Application/Services/AdminBusinessConfigService.cs b/RikiPath.Application/Services/AdminBusinessConfigService.cs index 5b9c771..cb9625b 100644 --- a/RikiPath.Application/Services/AdminBusinessConfigService.cs +++ b/RikiPath.Application/Services/AdminBusinessConfigService.cs @@ -103,12 +103,19 @@ public async Task> SaveSubscriptionPlanAsy "SUBSCRIPTION_PLAN_DESCRIPTION_TOO_LONG"); var category = request.PlanCategory?.Trim().ToLowerInvariant() ?? string.Empty; - if (!SubscriptionAccessService.SellableCategories.Contains(category)) + var isLegacyCategory = SubscriptionAccessService.IsLegacyAiCategory(category); + if (!SubscriptionAccessService.SellableCategories.Contains(category) && !(id.HasValue && isLegacyCategory)) return ApiResponse.Fail( - "Loại gói học không hợp lệ. Chỉ chấp nhận: self_study, speaking, writing, ai_grading, learning_path, combo.", + "Loại gói học không hợp lệ. Chỉ chấp nhận: Gói tự học (self_study), Gói AI (ai_pack), Gói kết hợp toàn diện (combo).", HttpStatusCode.BadRequest, "PLAN_CATEGORY_INVALID"); + if (isLegacyCategory && request.IsActive) + return ApiResponse.Fail( + "Nhóm gói AI cũ đã ngừng mở bán theo mô hình mới. Chỉ cho phép ngừng bán hoặc tạo lựa chọn mới trong Gói AI.", + HttpStatusCode.BadRequest, + "PLAN_CATEGORY_RETIRED"); + if (request.Price < 0 || request.Price != decimal.Truncate(request.Price) || request.Price > int.MaxValue) return ApiResponse.Fail( "Giá gói phải là số nguyên VND không âm.", @@ -121,18 +128,30 @@ public async Task> SaveSubscriptionPlanAsy HttpStatusCode.BadRequest, "SUBSCRIPTION_PLAN_PRICE_REQUIRED"); - var isCredit = SubscriptionAccessService.IsCreditCategory(category); - if (isCredit && request.DurationDays != 0) - return ApiResponse.Fail( - "Gói mua theo lượt AI phải có thời hạn bằng 0 ngày.", - HttpStatusCode.BadRequest, - "SUBSCRIPTION_PLAN_DURATION_INVALID"); - - if (!isCredit && request.DurationDays is < 1 or > 1095) - return ApiResponse.Fail( - "Thời hạn gói học phải từ 1 đến 1095 ngày.", - HttpStatusCode.BadRequest, - "SUBSCRIPTION_PLAN_DURATION_INVALID"); + if (string.Equals(category, SubscriptionAccessService.CategoryAiPack, StringComparison.OrdinalIgnoreCase)) + { + if (request.DurationDays is < 0 or > 1095) + return ApiResponse.Fail( + "Thời hạn sử dụng lượt AI phải từ 0 đến 1095 ngày (0 = không giới hạn ngày).", + HttpStatusCode.BadRequest, + "SUBSCRIPTION_PLAN_DURATION_INVALID"); + } + else if (isLegacyCategory) + { + if (request.DurationDays is < 0 or > 1095) + return ApiResponse.Fail( + "Thời hạn gói học phải từ 0 đến 1095 ngày.", + HttpStatusCode.BadRequest, + "SUBSCRIPTION_PLAN_DURATION_INVALID"); + } + else + { + if (request.DurationDays is < 1 or > 1095) + return ApiResponse.Fail( + "Thời hạn gói học phải từ 1 đến 1095 ngày.", + HttpStatusCode.BadRequest, + "SUBSCRIPTION_PLAN_DURATION_INVALID"); + } if (request.AiGradingQuota is < 0 or > 5000) return ApiResponse.Fail( @@ -142,7 +161,7 @@ public async Task> SaveSubscriptionPlanAsy if (category != SubscriptionAccessService.CategorySelfStudy && request.AiGradingQuota < 1) return ApiResponse.Fail( - "Gói kỹ năng hoặc lượt AI cần tối thiểu 1 lượt sử dụng AI.", + "Gói AI hoặc gói kết hợp cần tối thiểu 1 lượt sử dụng AI.", HttpStatusCode.BadRequest, "SUBSCRIPTION_PLAN_QUOTA_INVALID"); @@ -196,6 +215,22 @@ await uow.ExecuteInTransactionAsync(async token => return; } + var existingCategory = SubscriptionAccessService.ResolveCategory(existing, existing.Id); + if (!string.Equals(existingCategory, category, StringComparison.OrdinalIgnoreCase)) + { + var hasPaidPurchases = await uow.UserSubscriptions.Query() + .AsNoTracking() + .AnyAsync(s => !s.IsDeleted && s.SubscriptionPlanId == existing.Id && s.PaymentStatus == PaymentStatus.Paid, token); + if (hasPaidPurchases) + { + failure = ApiResponse.Fail( + "Không thể đổi nhóm của gói đã có đơn thanh toán để bảo toàn quyền lợi lịch sử.", + HttpStatusCode.Conflict, + "PLAN_CATEGORY_LOCKED_BY_ORDERS"); + return; + } + } + beforeJson = JsonSerializer.Serialize(new { existing.Id, diff --git a/RikiPath.Application/Services/LearningMomentService.cs b/RikiPath.Application/Services/LearningMomentService.cs index 64314a9..f598329 100644 --- a/RikiPath.Application/Services/LearningMomentService.cs +++ b/RikiPath.Application/Services/LearningMomentService.cs @@ -498,6 +498,7 @@ private async Task> BuildCandidatesAsync(int userId, DateT var ctaHref = category switch { SubscriptionAccessService.CategorySelfStudy or SubscriptionAccessService.CategoryCombo => "/lessons/", + SubscriptionAccessService.CategoryAiPack => activePath is null ? "/roadmap/" : "/riki/speaking/", SubscriptionAccessService.CategoryLearningPath => "/roadmap/", SubscriptionAccessService.CategorySpeaking => "/riki/speaking/", SubscriptionAccessService.CategoryWriting => "/riki/essay/", diff --git a/RikiPath.Application/Services/LearningPathGenerationTracker.cs b/RikiPath.Application/Services/LearningPathGenerationTracker.cs new file mode 100644 index 0000000..194441b --- /dev/null +++ b/RikiPath.Application/Services/LearningPathGenerationTracker.cs @@ -0,0 +1,130 @@ +using System.Collections.Concurrent; +using RikiPath.Application.Responses.LearningPaths; + +namespace RikiPath.Application.Services +{ + /// + /// Process-local, per-learner record of the AI learning-path generation the server is executing. + /// Registered as a singleton. Only the request that owns the generation writes to it, so the + /// status endpoint reports real stages and real batch counts, never a simulated progress. + /// + public sealed class LearningPathGenerationTracker + { + /// Finished results stay readable this long so a reloaded page can still recover them. + private static readonly TimeSpan FinishedRetention = TimeSpan.FromMinutes(30); + + /// A running entry with no update for this long can no longer be trusted (owner vanished). + private static readonly TimeSpan StaleRunning = TimeSpan.FromMinutes(15); + + private readonly ConcurrentDictionary states = new(); + + public Func UtcNowProvider { get; init; } = static () => DateTime.UtcNow; + + public LearningPathGenerationStatusResponse Get(int userId) + { + if (!states.TryGetValue(userId, out var current)) + return new LearningPathGenerationStatusResponse(); + + var now = UtcNowProvider(); + var expired = current.State == LearningPathGenerationStates.Running + ? now - (current.UpdatedAt ?? now) > StaleRunning + : now - (current.FinishedAt ?? now) > FinishedRetention; + if (!expired) + return Clone(current); + + states.TryRemove(new KeyValuePair(userId, current)); + return new LearningPathGenerationStatusResponse(); + } + + public void Start(int userId, string kind, bool continuesWhenClientLeaves) + { + var now = UtcNowProvider(); + states[userId] = new LearningPathGenerationStatusResponse + { + State = LearningPathGenerationStates.Running, + Kind = kind, + Stage = LearningPathGenerationStages.Preparing, + ContinuesWhenClientLeaves = continuesWhenClientLeaves, + StartedAt = now, + UpdatedAt = now, + }; + } + + /// Records the stage the server just entered. Ignored when no run is active for the learner. + public void ReportStage(int userId, string stage, int? completedBatches = null, int? totalBatches = null, + int? planDurationDays = null) + { + Update(userId, current => + { + if (current.State != LearningPathGenerationStates.Running) return null; + var next = Clone(current); + next.Stage = stage; + next.CompletedBatches = completedBatches ?? current.CompletedBatches; + next.TotalBatches = totalBatches ?? current.TotalBatches; + next.PlanDurationDays = planDurationDays ?? current.PlanDurationDays; + next.UpdatedAt = UtcNowProvider(); + return next; + }); + } + + public void Succeed(int userId, int? pathId) + { + Update(userId, current => + { + var next = Clone(current); + var now = UtcNowProvider(); + next.State = LearningPathGenerationStates.Succeeded; + next.Stage = null; + next.PathId = pathId; + if (next.TotalBatches.HasValue) next.CompletedBatches = next.TotalBatches; + next.UpdatedAt = now; + next.FinishedAt = now; + return next; + }); + } + + public void Fail(int userId, string? errorCode, string? errorMessage, bool? creditsPreserved) + { + Update(userId, current => + { + var next = Clone(current); + var now = UtcNowProvider(); + next.State = LearningPathGenerationStates.Failed; + next.Stage = null; + next.ErrorCode = errorCode; + next.ErrorMessage = errorMessage; + next.CreditsPreserved = creditsPreserved; + next.UpdatedAt = now; + next.FinishedAt = now; + return next; + }); + } + + private void Update(int userId, Func change) + { + while (states.TryGetValue(userId, out var current)) + { + var next = change(current); + if (next is null || states.TryUpdate(userId, next, current)) return; + } + } + + private static LearningPathGenerationStatusResponse Clone(LearningPathGenerationStatusResponse source) => new() + { + State = source.State, + Kind = source.Kind, + Stage = source.Stage, + CompletedBatches = source.CompletedBatches, + TotalBatches = source.TotalBatches, + PlanDurationDays = source.PlanDurationDays, + ContinuesWhenClientLeaves = source.ContinuesWhenClientLeaves, + StartedAt = source.StartedAt, + UpdatedAt = source.UpdatedAt, + FinishedAt = source.FinishedAt, + PathId = source.PathId, + ErrorCode = source.ErrorCode, + ErrorMessage = source.ErrorMessage, + CreditsPreserved = source.CreditsPreserved, + }; + } +} diff --git a/RikiPath.Application/Services/LearningPathService.cs b/RikiPath.Application/Services/LearningPathService.cs index dd7cd03..aa637da 100644 --- a/RikiPath.Application/Services/LearningPathService.cs +++ b/RikiPath.Application/Services/LearningPathService.cs @@ -24,7 +24,8 @@ public partial class LearningPathService( IAiLearningPathClient aiClient, IClaimService claimService, ILogger logger, - ILearnerSetupStateService? setupStateService = null) : ILearningPathService + ILearnerSetupStateService? setupStateService = null, + LearningPathGenerationTracker? generationTracker = null) : ILearningPathService { // ===== Constants ===== private const int MaxPlanDays = 730; // Giới hạn vận hành cho khoảng ôn trước ngày thi. @@ -238,6 +239,7 @@ private async Task> GenerateInternalAsync( HttpStatusCode.BadRequest, errorCode: "LEARNING_PATH_PLACEMENT_REQUIRED"); // ---------- 3. Đánh giá riêng từ vựng / ngữ pháp / đọc hiểu / nghe hiểu ---------- + generationTracker?.ReportStage(userId, LearningPathGenerationStages.Analyzing); var targetRank = JlptCurriculum.Rank(target.Code); var sectionAssessments = JlptSkillAssessmentPolicy.Assess(placementForPlan, target.Code); var assessments = ComputeSkillAssessments(sectionAssessments, targetRank); @@ -271,11 +273,14 @@ private async Task> GenerateInternalAsync( var totalStudyDays = studyDeadline.HasValue ? (studyDeadline.Value - today).Days : recommendedStudyDays; if (totalStudyDays <= 0) return ApiResponse.Fail( - "Không còn ngày ôn trước ba ngày nghỉ sát kỳ thi. Vui lòng chọn kỳ thi sau.", HttpStatusCode.BadRequest); + "Không còn ngày ôn trước ba ngày nghỉ sát kỳ thi. Vui lòng chọn kỳ thi sau.", HttpStatusCode.BadRequest, + errorCode: "LEARNING_PATH_EXAM_TOO_SOON"); if (totalStudyDays > MaxPlanDays) return ApiResponse.Fail( - "Chỉ hỗ trợ khoảng ôn tới ngày thi tối đa 730 ngày. Vui lòng chọn ngày thi gần hơn.", HttpStatusCode.BadRequest); + "Chỉ hỗ trợ khoảng ôn tới ngày thi tối đa 730 ngày. Vui lòng chọn ngày thi gần hơn.", HttpStatusCode.BadRequest, + errorCode: "LEARNING_PATH_PLAN_TOO_LONG"); var planDays = Math.Min(totalStudyDays, ShortPlanDays); + var totalBatches = (planDays + ShortPlanDays - 1) / ShortPlanDays; var horizon = LearningPathPlanningPolicy.ClassifyHorizon(assessments.Max(a => a.GapLevels), recommendedStudyDays, assessments.All(a => a.HasData)); @@ -360,6 +365,8 @@ private async Task> GenerateInternalAsync( { for (var offset = 0; offset < planDays; offset += ShortPlanDays) { + generationTracker?.ReportStage(userId, LearningPathGenerationStages.Designing, + completedBatches: offset / ShortPlanDays, totalBatches: totalBatches, planDurationDays: planDays); var batchDays = Math.Min(ShortPlanDays, planDays - offset); var batchPrompt = promptText .Replace($"Lập đúng {Math.Min(planDays, ShortPlanDays)} ngày", $"Lập đúng {batchDays} ngày") @@ -417,7 +424,8 @@ private async Task> GenerateInternalAsync( } if (batch is null) return ApiResponse.Fail( - $"AI trả về lịch không hợp lệ ({lastError}). Chưa lưu lộ trình dở dang.", HttpStatusCode.BadGateway); + $"AI trả về lịch không hợp lệ ({lastError}). Chưa lưu lộ trình dở dang.", HttpStatusCode.BadGateway, + errorCode: "LEARNING_PATH_AI_INVALID_OUTPUT"); skillFeedback ??= batch.SkillFeedback; summaries.Add(batch.Summary); focusTopics.AddRange(batch.FocusTopics); @@ -478,6 +486,8 @@ private async Task> GenerateInternalAsync( feasibility += $" Lộ trình AI chỉ xếp {planDays} ngày ôn trước mắt; sau chặng này, hãy làm đề thi thử JLPT chung của hệ thống để đánh giá và tiếp tục ôn luyện."; // ---------- 7. Save DRAFT or first ACTIVE in a learner-row-locked transaction ---------- + generationTracker?.ReportStage(userId, LearningPathGenerationStages.Saving, + completedBatches: totalBatches, totalBatches: totalBatches, planDurationDays: planDays); try { var generatedAt = BusinessDateHelper.EnsureUtc(UtcNowProvider()); @@ -523,6 +533,7 @@ private async Task> GenerateInternalAsync( ContentCoverageWarnings = coverageWarnings, Phases = BuildPhases(today, planDays), Summary = aiResult.Summary, + IsTestFixture = RikiPath.Application.Common.LearningPathTestFixture.IsTestFixture(aiResult.Summary), Strengths = strengths, Weaknesses = weaknesses, Feasibility = feasibility, @@ -926,6 +937,7 @@ private async Task RestoreStoredPathAsync( response.BaseActivePathId = stored.BaseActivePathId; response.PreviewExpiresAt = stored.PreviewExpiresAt; response.ConfirmedAt = stored.ConfirmedAt; + response.IsTestFixture = RikiPath.Application.Common.LearningPathTestFixture.IsTestFixture(response.Summary); RefreshDayAvailability(response); return response; } diff --git a/RikiPath.Application/Services/SubscriptionAccessService.cs b/RikiPath.Application/Services/SubscriptionAccessService.cs index e684da9..34cf216 100644 --- a/RikiPath.Application/Services/SubscriptionAccessService.cs +++ b/RikiPath.Application/Services/SubscriptionAccessService.cs @@ -23,6 +23,7 @@ public sealed class SubscriptionAccessService( public const int OrderPrefix = 900_000_000; public const string CategorySelfStudy = "self_study"; + public const string CategoryAiPack = "ai_pack"; public const string CategorySpeaking = "speaking"; public const string CategoryWriting = "writing"; public const string CategoryAiGrading = "ai_grading"; @@ -33,13 +34,31 @@ public sealed class SubscriptionAccessService( public static readonly IReadOnlySet SellableCategories = new HashSet(StringComparer.OrdinalIgnoreCase) { CategorySelfStudy, + CategoryAiPack, + CategoryCombo, + }; + + public static readonly IReadOnlySet LegacyAiCategories = new HashSet(StringComparer.OrdinalIgnoreCase) + { CategorySpeaking, CategoryWriting, CategoryAiGrading, CategoryLearningPath, + }; + + public static readonly IReadOnlySet UnifiedAiCategories = new HashSet(StringComparer.OrdinalIgnoreCase) + { + CategorySelfStudy, + CategoryAiPack, CategoryCombo, }; + public static bool IsLegacyAiCategory(string? category) + => !string.IsNullOrWhiteSpace(category) && LegacyAiCategories.Contains(category.Trim()); + + public static bool IsUnifiedAiCategory(string? category) + => !string.IsNullOrWhiteSpace(category) && UnifiedAiCategories.Contains(category.Trim()); + public static bool IsUnlimitedExpiry(DateTime? endDate) => !endDate.HasValue || endDate.Value.Year >= 2099; @@ -51,7 +70,8 @@ public static string ResolveCategory(SubscriptionPlan? plan, int planId) return CategoryMentorLegacy; var normalized = plan.PlanCategory?.Trim().ToLowerInvariant(); - if (!string.IsNullOrEmpty(normalized) && SellableCategories.Contains(normalized)) + if (!string.IsNullOrEmpty(normalized) && + (SellableCategories.Contains(normalized) || LegacyAiCategories.Contains(normalized))) { if (normalized == CategorySelfStudy && planId is SpeakingPlan or WritingPlan or GradingCredit or LearningPathCredit) { @@ -80,7 +100,8 @@ public static string ResolveCategory(SubscriptionPlan? plan, int planId) } public static bool IsCreditCategory(string? category) - => string.Equals(category, CategoryAiGrading, StringComparison.OrdinalIgnoreCase) + => string.Equals(category, CategoryAiPack, StringComparison.OrdinalIgnoreCase) + || string.Equals(category, CategoryAiGrading, StringComparison.OrdinalIgnoreCase) || string.Equals(category, CategoryLearningPath, StringComparison.OrdinalIgnoreCase); public static bool IsCredit(int planId) => planId is GradingCredit or LearningPathCredit; @@ -90,7 +111,7 @@ public static bool IsSellable(SubscriptionPlan? plan) && plan.IsActive && !plan.IsDeleted && plan.MeetingSessionCount == 0 - && ResolveCategory(plan, plan.Id) != CategoryMentorLegacy; + && SellableCategories.Contains(ResolveCategory(plan, plan.Id)); private static string OrderCategory(UserSubscription order) => !string.IsNullOrWhiteSpace(order.PlanCategorySnapshot) @@ -149,11 +170,13 @@ public async Task GetAccessAsync(CancellationToken ct) : IsUnlimitedExpiry(studyExpiresAt) ? null : (int)Math.Ceiling((studyExpiresAt!.Value - now).TotalDays); - var grading = active.Where(s => OrderCategory(s) is CategoryAiGrading or CategorySelfStudy or CategoryCombo) - .Sum(RemainingAi); - // TEMPORARY AI TEST ACCESS: restore the purchase-based Speaking/Writing checks when testing ends. - // var speaking = active.Any(s => OrderCategory(s) is CategorySpeaking or CategoryCombo) || study is not null || grading > 0; - // var writing = active.Any(s => OrderCategory(s) is CategoryWriting or CategoryCombo) || study is not null || grading > 0; + var unifiedAi = SaturatingSumRemainingAi(active.Where(s => IsUnifiedAiCategory(OrderCategory(s)))); + var aiGradingLegacy = SaturatingSumRemainingAi(active.Where(s => OrderCategory(s) == CategoryAiGrading)); + var speakingLegacy = SaturatingSumRemainingAi(active.Where(s => OrderCategory(s) == CategorySpeaking)); + var writingLegacy = SaturatingSumRemainingAi(active.Where(s => OrderCategory(s) == CategoryWriting)); + var learningPathLegacy = SaturatingSumRemainingAi(active.Where(s => OrderCategory(s) == CategoryLearningPath)); + + var grading = SaturatingSum([unifiedAi, aiGradingLegacy]); var allFeatures = await unitOfWork.Features.Query().AsNoTracking() .Where(f => !f.IsDeleted && f.Category != CategoryMentorLegacy) .OrderBy(f => f.SortOrder).ThenBy(f => f.Id) @@ -168,25 +191,34 @@ public async Task GetAccessAsync(CancellationToken ct) LockReason = null, UnlockPath = null } : entitlement; }).ToList(); - var speaking = evaluatedFeatures.FirstOrDefault(f => f.Code == FeatureCodes.AiSpeaking)?.Allowed - ?? (active.Any(s => OrderCategory(s) is CategorySpeaking or CategoryCombo) || study is not null || grading > 0); - var writing = evaluatedFeatures.FirstOrDefault(f => f.Code == FeatureCodes.AiWriting)?.Allowed - ?? (active.Any(s => OrderCategory(s) is CategoryWriting or CategoryCombo) || study is not null || grading > 0); + var speakingAllowed = evaluatedFeatures.FirstOrDefault(f => f.Code == FeatureCodes.AiSpeaking)?.Allowed ?? false; + var writingAllowed = evaluatedFeatures.FirstOrDefault(f => f.Code == FeatureCodes.AiWriting)?.Allowed ?? false; + var legacyBalances = BuildLegacyAiBalances(active); + var aiFeatureCosts = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + ["speaking"] = GetCreditCost("speaking"), + ["writing"] = GetCreditCost("writing"), + ["learning_path"] = GetCreditCost("learning_path"), + [MockTestExplanationService.CreditFeature] = GetCreditCost(MockTestExplanationService.CreditFeature), + }; return new StudyAccessResponse( study is not null, study is null ? null : (study.PlanNameSnapshot ?? study.SubscriptionPlan?.Name), - speaking, - writing, + speakingAllowed, + writingAllowed, grading, - active.Where(s => OrderCategory(s) == CategorySpeaking).Sum(RemainingAi), - active.Where(s => OrderCategory(s) == CategoryWriting).Sum(RemainingAi), - active.Where(s => OrderCategory(s) == CategoryLearningPath).Sum(RemainingAi), + speakingLegacy, + writingLegacy, + learningPathLegacy, 0, purchases.Select(s => ToPurchasedStudyPlan(s, now)).ToList(), studyExpiresAt, studyDaysRemaining, - evaluatedFeatures); + evaluatedFeatures, + unifiedAi, + legacyBalances, + aiFeatureCosts); } public async Task GetPurchaseHistoryAsync( @@ -338,7 +370,7 @@ public async Task EvaluateFeatureAsync(string featureCode var errCode = evaluated.AccessSource == "LOCKED" && evaluated.Code == FeatureCodes.LessonsContent && mode == FeatureAccessModes.PlanRequired ? "SELF_STUDY_PACKAGE_REQUIRED" - : evaluated.RequiresCredit && evaluated.CreditsRemaining <= 0 && + : evaluated.RequiresCredit && evaluated.CreditsRemaining < evaluated.CreditCost && (mode == FeatureAccessModes.CreditRequired || (mode == FeatureAccessModes.PlanAndCredit && evaluated.GrantedByPlanName is not null)) ? "AI_CREDIT_REQUIRED" : "FEATURE_PLAN_REQUIRED"; @@ -392,14 +424,14 @@ internal static FeatureEntitlementDto EvaluateFeaturePolicy( return new FeatureEntitlementDto( feature.Id, feature.Code, feature.Name, feature.Description, feature.Category, mode, feature.IsCoreFree, false, "DISABLED", null, false, 0, - SuspendedMessage, null, routes); + SuspendedMessage, null, routes, 0); } if (mode == FeatureAccessModes.Free) { return new FeatureEntitlementDto( feature.Id, feature.Code, feature.Name, feature.Description, feature.Category, - mode, feature.IsCoreFree, true, "FREE", null, false, 0, null, null, routes); + mode, feature.IsCoreFree, true, "FREE", null, false, 0, null, null, routes, 0); } var matchingPlan = activeGrants.FirstOrDefault(grant => @@ -412,6 +444,7 @@ internal static FeatureEntitlementDto EvaluateFeaturePolicy( : SaturatingSum(activeGrants .Where(grant => SupportsCredit(grant.Category, creditKey)) .Select(grant => grant.AiQuotaRemaining)); + var creditCost = string.IsNullOrWhiteSpace(creditKey) ? 0 : GetCreditCost(creditKey); return mode switch { @@ -425,30 +458,30 @@ matchingPlan is not null ? "Bạn cần gói tự học đang hiệu lực." : $"Tính năng {feature.Name} yêu cầu gói học phù hợp."), matchingPlan is not null ? null : "/plans/", - routes), + routes, 0), FeatureAccessModes.CreditRequired => new FeatureEntitlementDto( feature.Id, feature.Code, feature.Name, feature.Description, feature.Category, - mode, false, creditsRemaining > 0, creditsRemaining > 0 ? "CREDIT" : "LOCKED", + mode, false, creditsRemaining >= creditCost, creditsRemaining >= creditCost ? "CREDIT" : "LOCKED", null, true, creditsRemaining, - creditsRemaining > 0 ? null : "Bạn chưa có lượt AI cho tính năng này. Vào Mua gói để mua thêm lượt.", - creditsRemaining > 0 ? null : "/plans/", - routes), + creditsRemaining >= creditCost ? null : "Bạn không đủ lượt AI để thực hiện thao tác này.", + creditsRemaining >= creditCost ? null : "/plans/", + routes, creditCost), FeatureAccessModes.PlanAndCredit => new FeatureEntitlementDto( feature.Id, feature.Code, feature.Name, feature.Description, feature.Category, - mode, false, matchingPlan is not null && creditsRemaining > 0, - matchingPlan is not null && creditsRemaining > 0 ? "PLAN_AND_CREDIT" : "LOCKED", + mode, false, matchingPlan is not null && creditsRemaining >= creditCost, + matchingPlan is not null && creditsRemaining >= creditCost ? "PLAN_AND_CREDIT" : "LOCKED", matchingPlan?.PlanName, true, creditsRemaining, matchingPlan is null ? $"Tính năng {feature.Name} yêu cầu gói học phù hợp và lượt AI." - : (creditsRemaining > 0 ? null : "Bạn đã hết lượt AI khả dụng cho tính năng này."), - matchingPlan is not null && creditsRemaining > 0 ? null : "/plans/", - routes), + : (creditsRemaining >= creditCost ? null : "Bạn không đủ lượt AI để thực hiện thao tác này."), + matchingPlan is not null && creditsRemaining >= creditCost ? null : "/plans/", + routes, creditCost), _ => new FeatureEntitlementDto( feature.Id, feature.Code, feature.Name, feature.Description, feature.Category, - FeatureAccessModes.Free, feature.IsCoreFree, true, "FREE", null, false, 0, null, null, routes), + FeatureAccessModes.Free, feature.IsCoreFree, true, "FREE", null, false, 0, null, null, routes, 0), }; } @@ -482,15 +515,70 @@ public static string EffectiveState(FeatureEntitlementDto evaluated) }; } - private static bool SupportsCredit(string category, string feature) => feature switch + private static bool SupportsCredit(string category, string feature) { - "learning_path" => category is CategoryLearningPath or CategoryCombo, - "speaking" => category is CategorySpeaking or CategoryAiGrading or CategorySelfStudy or CategoryCombo, - "writing" => category is CategoryWriting or CategoryAiGrading or CategorySelfStudy or CategoryCombo, - MockTestExplanationService.CreditFeature => category is CategoryAiGrading or CategorySelfStudy or CategoryCombo, - _ => false + if (IsUnifiedAiCategory(category)) + return feature is "speaking" or "writing" or "learning_path" or MockTestExplanationService.CreditFeature; + + return feature switch + { + "learning_path" => string.Equals(category, CategoryLearningPath, StringComparison.OrdinalIgnoreCase), + "speaking" => string.Equals(category, CategorySpeaking, StringComparison.OrdinalIgnoreCase) + || string.Equals(category, CategoryAiGrading, StringComparison.OrdinalIgnoreCase), + "writing" => string.Equals(category, CategoryWriting, StringComparison.OrdinalIgnoreCase) + || string.Equals(category, CategoryAiGrading, StringComparison.OrdinalIgnoreCase), + MockTestExplanationService.CreditFeature => string.Equals(category, CategoryAiGrading, StringComparison.OrdinalIgnoreCase), + _ => false, + }; + } + + public static string? FeatureCodeForCreditKey(string? feature) => feature?.Trim().ToLowerInvariant() switch + { + "speaking" => FeatureCodes.AiSpeaking, + "writing" => FeatureCodes.AiWriting, + "learning_path" => FeatureCodes.AiLearningPath, + MockTestExplanationService.CreditFeature => FeatureCodes.AiMockExplanation, + _ => null, + }; + + public static int GetCreditCost(string? feature) => feature?.Trim().ToLowerInvariant() switch + { + "speaking" => 1, + "writing" => 1, + "learning_path" => 1, + MockTestExplanationService.CreditFeature => 1, + _ => 1, }; + private static List BuildLegacyAiBalances(IReadOnlyList activeOrders) + { + var orderPriority = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + [CategorySpeaking] = ("Luyện nói AI (gói cũ)", 0), + [CategoryWriting] = ("Luyện viết AI (gói cũ)", 1), + [CategoryAiGrading] = ("Chấm AI nói/viết (gói cũ)", 2), + [CategoryLearningPath] = ("Tạo lộ trình AI (gói cũ)", 3), + }; + + return activeOrders + .Where(s => IsLegacyAiCategory(OrderCategory(s)) && RemainingAi(s) > 0) + .GroupBy(OrderCategory, StringComparer.OrdinalIgnoreCase) + .Select(g => + { + var remaining = SaturatingSumRemainingAi(g); + var earliest = g + .Where(s => s.EndDate.HasValue && !IsUnlimitedExpiry(s.EndDate)) + .Select(s => (DateTime?)DateTime.SpecifyKind(s.EndDate!.Value, DateTimeKind.Utc)) + .OrderBy(d => d) + .FirstOrDefault(); + var label = orderPriority.TryGetValue(g.Key, out var meta) ? meta.Label : g.Key; + return (Sort: meta.Order, Item: new LegacyAiBalanceDto(g.Key, label, remaining, earliest)); + }) + .OrderBy(x => x.Sort) + .Select(x => x.Item) + .ToList(); + } + /// PayOS hosted-checkout link lifetime for a self-study order; the order is held Pending for the same window. public static readonly TimeSpan PaymentLinkLifetime = TimeSpan.FromMinutes(15); private static readonly TimeSpan LinkCreationGrace = TimeSpan.FromSeconds(45); @@ -777,10 +865,14 @@ internal static void Activate(UserSubscription order, string? reference, DateTim order.PaymentStatus = PaymentStatus.Paid; order.PaymentTransactionId = reference; order.StartDate = now; - if (IsCreditCategory(category) || IsCredit(order.SubscriptionPlanId)) + if (durationDays <= 0 || IsCredit(order.SubscriptionPlanId)) { order.EndDate = null; } + else if (string.Equals(category, CategoryAiPack, StringComparison.OrdinalIgnoreCase)) + { + order.EndDate = now.AddDays(durationDays); + } else { var effectiveStart = stackFromUtc.HasValue && stackFromUtc.Value > now ? stackFromUtc.Value : now; @@ -799,7 +891,7 @@ public async Task> UseAiAsync(string feature, Func FeatureCodes.AiLearningPath, "speaking" => FeatureCodes.AiSpeaking, @@ -807,9 +899,9 @@ public async Task> UseAiAsync(string feature, Func FeatureCodes.AiMockExplanation, _ => null, }; - if (featureCode is not null) + if (testFeatureCode is not null) { - var decision = await EvaluateFeatureAsync(featureCode, ct); + var decision = await EvaluateFeatureAsync(testFeatureCode, ct); if (!decision.Allowed) return ApiResponse.Fail(decision.Message ?? SuspendedMessage, decision.StatusCode, errorCode: decision.ErrorCode ?? "FEATURE_DISABLED"); @@ -817,26 +909,109 @@ public async Task> UseAiAsync(string feature, Func !f.IsDeleted && f.Code == featureCode, ct); + if (featureEntity is not null) + mode = EffectiveMode(featureEntity); + } + + if (mode == FeatureAccessModes.Disabled) + return ApiResponse.Fail(SuspendedMessage, HttpStatusCode.Forbidden, errorCode: "FEATURE_DISABLED"); + + if (mode == FeatureAccessModes.Free) + return await operation(); + + if (mode == FeatureAccessModes.PlanRequired) + { + var planCheck = await EvaluateFeatureAsync(featureCode!, ct); + if (!planCheck.Allowed) + return ApiResponse.Fail( + planCheck.Message ?? "Bạn cần gói học đang hiệu lực.", + planCheck.StatusCode, + errorCode: planCheck.ErrorCode ?? "FEATURE_PLAN_REQUIRED"); + return await operation(); + } + + var cost = GetCreditCost(feature); var userId = actor.Id; - int? reservationId = null; + List<(int OrderId, int Taken)> reservations = []; + var missingRequiredPlan = false; + string? planRequiredMessage = null; + await unitOfWork.ExecuteInTransactionAsync(async token => { + reservations.Clear(); + missingRequiredPlan = false; if (await unitOfWork.UserAccounts.GetByIdForUpdateAsync(userId, token) is null) return; var now = DateTime.UtcNow; - var orders = await unitOfWork.UserSubscriptions.Query() - .Include(s => s.SubscriptionPlan) - .Where(s => s.UserId == userId && !s.IsDeleted && s.PaymentStatus == PaymentStatus.Paid && - s.AiGradingUsedCount < s.AiGradingQuota) - .OrderBy(s => s.EndDate == null).ThenBy(s => s.EndDate).ThenBy(s => s.Id).ToListAsync(token); - var credit = orders.FirstOrDefault(s => IsActive(s, now) && Supports(s, feature)); - if (credit is null) return; - credit.AiGradingUsedCount++; - await unitOfWork.SaveChangesAsync(token); - reservationId = credit.Id; + var query = unitOfWork.UserSubscriptions.Query(); + query = mode == FeatureAccessModes.PlanAndCredit + ? query.Include(s => s.SubscriptionPlan).ThenInclude(p => p!.Features) + : query.Include(s => s.SubscriptionPlan); + + var activePaid = (await query + .Where(s => s.UserId == userId && !s.IsDeleted && s.PaymentStatus == PaymentStatus.Paid) + .ToListAsync(token)) + .Where(s => IsActive(s, now)) + .ToList(); + + if (mode == FeatureAccessModes.PlanAndCredit && featureEntity is not null) + { + var grants = ToGrantSnapshots(activePaid); + var hasPlan = grants.Any(grant => + grant.FeatureIds.Contains(featureEntity.Id) || + (featureEntity.Code == FeatureCodes.LessonsContent && grant.Category is CategorySelfStudy or CategoryCombo)); + if (!hasPlan) + { + missingRequiredPlan = true; + planRequiredMessage = $"Tính năng {featureEntity.Name} yêu cầu gói học phù hợp và lượt AI."; + return; + } + } + + // Draw narrow legacy scoped credits before versatile unified credits, and expiring credits before non-expiring credits. + var eligible = activePaid + .Where(s => RemainingAi(s) > 0 && Supports(s, feature)) + .OrderBy(s => IsUnifiedAiCategory(OrderCategory(s)) ? 1 : 0) + .ThenBy(s => s.EndDate == null ? 1 : 0) + .ThenBy(s => s.EndDate) + .ThenBy(s => s.Id) + .ToList(); + + if (SaturatingSumRemainingAi(eligible) < cost) + return; + + var remainingCost = cost; + foreach (var order in eligible) + { + if (remainingCost <= 0) break; + var available = RemainingAi(order); + var take = Math.Min(available, remainingCost); + if (take <= 0) continue; + order.AiGradingUsedCount += take; + remainingCost -= take; + reservations.Add((order.Id, take)); + } + + if (remainingCost == 0) + await unitOfWork.SaveChangesAsync(token); + else + reservations.Clear(); }, ct); - if (reservationId is null) - return ApiResponse.Fail("Bạn chưa có lượt AI cho tính năng này. Vào Mua gói để mua thêm lượt.", + if (missingRequiredPlan) + return ApiResponse.Fail( + planRequiredMessage ?? "Tính năng này yêu cầu gói học phù hợp.", + HttpStatusCode.Forbidden, + errorCode: "FEATURE_PLAN_REQUIRED"); + + if (reservations.Count == 0) + return ApiResponse.Fail("Bạn không đủ lượt AI để thực hiện thao tác này.", HttpStatusCode.Forbidden, errorCode: "AI_CREDIT_REQUIRED"); var succeeded = false; @@ -845,21 +1020,24 @@ await unitOfWork.ExecuteInTransactionAsync(async token => var result = await operation(); succeeded = result.IsSuccess && (delivered is null || delivered(result.Result)); if (succeeded) - logger?.LogInformation("AI credit consumed. UserId={UserId} Feature={Feature} PurchaseId={PurchaseId} Credits={Credits}", - userId, feature, reservationId.Value, 1); + logger?.LogInformation("AI credit consumed. UserId={UserId} Feature={Feature} Orders={Orders} Credits={Credits}", + userId, feature, string.Join(',', reservations.Select(r => $"{r.OrderId}:{r.Taken}")), cost); return result; } finally { - if (!succeeded) + if (!succeeded && reservations.Count > 0) await unitOfWork.ExecuteInTransactionAsync(async token => { await unitOfWork.UserAccounts.GetByIdForUpdateAsync(userId, token); - // An atomic update avoids overwriting usage from another request. - await unitOfWork.UserSubscriptions.Query() - .Where(s => s.Id == reservationId.Value && s.AiGradingUsedCount > 0) - .ExecuteUpdateAsync(setters => setters.SetProperty(s => s.AiGradingUsedCount, - s => s.AiGradingUsedCount - 1), token); + foreach (var (orderId, taken) in reservations) + { + // An atomic update avoids overwriting usage from another request. + await unitOfWork.UserSubscriptions.Query() + .Where(s => s.Id == orderId && s.AiGradingUsedCount >= taken) + .ExecuteUpdateAsync(setters => setters.SetProperty(s => s.AiGradingUsedCount, + s => s.AiGradingUsedCount - taken), token); + } }, CancellationToken.None); } } @@ -903,6 +1081,12 @@ public sealed record StudyPlanFeatureDto( string Category, string AccessMode); +public sealed record LegacyAiBalanceDto( + string Category, + string Label, + int Remaining, + DateTime? EarliestExpiryUtc = null); + public sealed record FeatureEntitlementDto( int FeatureId, string Code, @@ -918,7 +1102,8 @@ public sealed record FeatureEntitlementDto( int CreditsRemaining, string? LockReason, string? UnlockPath, - IReadOnlyList Routes); + IReadOnlyList Routes, + int CreditCost = 0); public sealed record FeatureAccessDecision( bool Allowed, @@ -960,4 +1145,7 @@ public sealed record StudyAccessResponse(bool Active, string? PlanName, bool Spe int AiGradingUsesRemaining, int SpeakingUsesRemaining, int WritingUsesRemaining, int LearningPathUsesRemaining, int MentorSessionsRemaining, IReadOnlyList Purchases, DateTime? SelfStudyExpiresAt, int? SelfStudyDaysRemaining, - IReadOnlyList? Features = null); + IReadOnlyList? Features = null, + int UnifiedAiUsesRemaining = 0, + IReadOnlyList? LegacyAiBalances = null, + IReadOnlyDictionary? AiFeatureCosts = null); diff --git a/RikiPath.Infrastructure/Clients/M4E2eAiLearningPathClient.cs b/RikiPath.Infrastructure/Clients/M4E2eAiLearningPathClient.cs index 7e15e94..119e5ea 100644 --- a/RikiPath.Infrastructure/Clients/M4E2eAiLearningPathClient.cs +++ b/RikiPath.Infrastructure/Clients/M4E2eAiLearningPathClient.cs @@ -57,7 +57,7 @@ public Task GenerateLearningPathJsonAsync( var response = new { - summary = "[M4E2E TEST STUB — NOT REAL AI OUTPUT] Deterministic integration-test response.", + summary = $"{RikiPath.Application.Common.LearningPathTestFixture.SummaryMarker} Deterministic integration-test response.", skillFeedback = new[] { "vocabulary", "grammar", "reading", "listening" }.Select(skill => new { skillCode = skill, comment = "Dữ liệu mô phỏng, không phải nhận xét AI thật.", recommendation = "Chỉ dùng để kiểm thử." }), strengths = new[] { "M4E2E test data" }, diff --git a/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.Designer.cs b/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.Designer.cs new file mode 100644 index 0000000..261ad71 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.Designer.cs @@ -0,0 +1,14703 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using RikiPath.Infrastructure; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20261203073836_RemoveLegacyMockPublishMetadata")] + partial class RemoveLegacyMockPublishMetadata + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("FeatureSubscriptionPlan", b => + { + b.Property("FeaturesId") + .HasColumnType("integer"); + + b.Property("SubscriptionPlansId") + .HasColumnType("integer"); + + b.HasKey("FeaturesId", "SubscriptionPlansId"); + + b.HasIndex("SubscriptionPlansId"); + + b.ToTable("FeatureSubscriptionPlan"); + + b.HasData( + new + { + FeaturesId = 1, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 1 + }, + new + { + FeaturesId = 1, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 2 + }, + new + { + FeaturesId = 1, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 3 + }, + new + { + FeaturesId = 1, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 4 + }, + new + { + FeaturesId = 1, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 5 + }, + new + { + FeaturesId = 1, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 2, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 3, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 4, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 5, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 6 + }, + new + { + FeaturesId = 7, + SubscriptionPlansId = 7 + }, + new + { + FeaturesId = 8, + SubscriptionPlansId = 7 + }, + new + { + FeaturesId = 13, + SubscriptionPlansId = 8101 + }, + new + { + FeaturesId = 14, + SubscriptionPlansId = 8102 + }, + new + { + FeaturesId = 6, + SubscriptionPlansId = 8103 + }, + new + { + FeaturesId = 12, + SubscriptionPlansId = 8104 + }, + new + { + FeaturesId = 7, + SubscriptionPlansId = 8105 + }, + new + { + FeaturesId = 8, + SubscriptionPlansId = 8105 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.AdminAuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ActorUserId") + .HasColumnType("integer"); + + b.Property("AfterJson") + .HasColumnType("text"); + + b.Property("BeforeJson") + .HasColumnType("text"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("EntityId") + .HasColumnType("integer"); + + b.Property("EntityType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedAtUtc"); + + b.HasIndex("EntityType", "EntityId"); + + b.ToTable("AdminAuditLogs", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.AiCreditTopUp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("PaymentTransactionId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("TotalAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "PaymentStatus"); + + b.ToTable("AiCreditTopUps"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.AiRuntimeConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ProtectedSecretsJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SettingsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedByAdminId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AiRuntimeConfigurations", null, t => + { + t.HasCheckConstraint("CK_AiRuntimeConfiguration_Singleton", "\"Id\" = 1 AND \"Revision\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateTypeId") + .HasColumnType("integer") + .HasColumnName("CertificationId"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateTypeId", "Code") + .IsUnique(); + + b.ToTable("CertificateLevels", null, t => + { + t.HasCheckConstraint("CK_CertificateLevels_SortOrder", "\"SortOrder\" >= 1"); + }); + + b.HasData( + new + { + Id = 1, + CertificateTypeId = 1, + Code = "N5", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "JLPT N5", + IsDeleted = false, + Revision = 1, + SortOrder = 1 + }, + new + { + Id = 2, + CertificateTypeId = 1, + Code = "N4", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "JLPT N4", + IsDeleted = false, + Revision = 1, + SortOrder = 2 + }, + new + { + Id = 3, + CertificateTypeId = 1, + Code = "N3", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "JLPT N3", + IsDeleted = false, + Revision = 1, + SortOrder = 3 + }, + new + { + Id = 4, + CertificateTypeId = 1, + Code = "N2", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "JLPT N2", + IsDeleted = false, + Revision = 1, + SortOrder = 4 + }, + new + { + Id = 5, + CertificateTypeId = 1, + Code = "N1", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "JLPT N1", + IsDeleted = false, + Revision = 1, + SortOrder = 5 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer") + .HasColumnName("CertificationLevelId"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("DurationMinutes") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MaxScore") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PassingScore") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId", "Code") + .IsUnique() + .HasFilter("\"IsDeleted\" = false"); + + b.ToTable("CertificateSections"); + + b.HasData( + new + { + Id = 1, + CertificateLevelId = 1, + Code = "N5_VOCAB", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5285), + Description = "Phần thi kiểm tra chữ Hán, cách đọc và từ vựng cấp độ N5", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Từ vựng)", + PassingScore = 0, + SortOrder = 1 + }, + new + { + Id = 2, + CertificateLevelId = 1, + Code = "N5_GRAMMAR", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5292), + Description = "Phần thi kiểm tra cấu trúc ngữ pháp và sắp xếp câu cấp độ N5", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Ngữ pháp)", + PassingScore = 0, + SortOrder = 2 + }, + new + { + Id = 3, + CertificateLevelId = 1, + Code = "N5_LISTENING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5294), + Description = "Phần thi nghe hiểu tình huống giao tiếp hàng ngày cấp độ N5", + IsDeleted = false, + MaxScore = 0, + Name = "Nghe hiểu", + PassingScore = 0, + SortOrder = 4 + }, + new + { + Id = 16, + CertificateLevelId = 1, + Code = "N5_READING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5308), + Description = "Phần thi đọc hiểu văn bản, thông báo và đoạn hội thoại ngắn cấp độ N5", + IsDeleted = false, + MaxScore = 0, + Name = "Đọc hiểu", + PassingScore = 0, + SortOrder = 3 + }, + new + { + Id = 4, + CertificateLevelId = 2, + Code = "N4_VOCAB", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5295), + Description = "Phần thi kiểm tra chữ Hán, cách đọc và từ vựng cấp độ N4", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Từ vựng)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 5, + CertificateLevelId = 2, + Code = "N4_GRAMMAR", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5296), + Description = "Phần thi kiểm tra cấu trúc ngữ pháp và sắp xếp câu cấp độ N4", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Ngữ pháp)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 6, + CertificateLevelId = 2, + Code = "N4_READING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5297), + Description = "Phần thi đọc hiểu văn bản, thông báo và biểu mẫu cấp độ N4", + IsDeleted = false, + MaxScore = 0, + Name = "Đọc hiểu", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 7, + CertificateLevelId = 2, + Code = "N4_LISTENING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5298), + Description = "Phần thi nghe hiểu hội thoại và tình huống thực tế cấp độ N4", + IsDeleted = false, + MaxScore = 0, + Name = "Nghe hiểu", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 8, + CertificateLevelId = 3, + Code = "N3_VOCAB", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5300), + Description = "Phần thi kiểm tra chữ Hán, cách đọc và từ vựng cấp độ N3", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Từ vựng)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 9, + CertificateLevelId = 3, + Code = "N3_GRAMMAR", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5301), + Description = "Phần thi kiểm tra cấu trúc ngữ pháp và sắp xếp câu cấp độ N3", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Ngữ pháp)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 10, + CertificateLevelId = 3, + Code = "N3_READING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5302), + Description = "Phần thi đọc hiểu văn bản, thông báo và biểu mẫu cấp độ N3", + IsDeleted = false, + MaxScore = 0, + Name = "Đọc hiểu", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 11, + CertificateLevelId = 3, + Code = "N3_LISTENING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5303), + Description = "Phần thi nghe hiểu hội thoại và tình huống thực tế cấp độ N3", + IsDeleted = false, + MaxScore = 0, + Name = "Nghe hiểu", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 12, + CertificateLevelId = 4, + Code = "N2_VOCAB", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5304), + Description = "Phần thi kiểm tra chữ Hán, cách đọc và từ vựng cấp độ N2", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Từ vựng)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 13, + CertificateLevelId = 4, + Code = "N2_GRAMMAR", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5305), + Description = "Phần thi kiểm tra cấu trúc ngữ pháp và sắp xếp câu cấp độ N2", + IsDeleted = false, + MaxScore = 0, + Name = "Kiến thức ngôn ngữ (Ngữ pháp)", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 14, + CertificateLevelId = 4, + Code = "N2_READING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5306), + Description = "Phần thi đọc hiểu văn bản, thông báo và biểu mẫu cấp độ N2", + IsDeleted = false, + MaxScore = 0, + Name = "Đọc hiểu", + PassingScore = 0, + SortOrder = 0 + }, + new + { + Id = 15, + CertificateLevelId = 4, + Code = "N2_LISTENING", + CreatedDate = new DateTime(2026, 10, 31, 11, 13, 24, 991, DateTimeKind.Utc).AddTicks(5307), + Description = "Phần thi nghe hiểu hội thoại và tình huống thực tế cấp độ N2", + IsDeleted = false, + MaxScore = 0, + Name = "Nghe hiểu", + PassingScore = 0, + SortOrder = 0 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("CertificateTypes", null, t => + { + t.HasCheckConstraint("CK_CertificateTypes_SortOrder", "\"SortOrder\" >= 1"); + }); + + b.HasData( + new + { + Id = 1, + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese-Language Proficiency Test", + IsActive = true, + IsDeleted = false, + Name = "JLPT", + Revision = 1, + SortOrder = 1 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ClassQuiz", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DueAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("PublishedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("QuestionCount") + .HasColumnType("integer"); + + b.Property("QuestionSnapshotJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SkillCodes") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("StructureKey") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TimeLimitMinutes") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("MentorId"); + + b.HasIndex("CohortId", "IsDeleted", "DueAtUtc"); + + b.ToTable("ClassQuizzes", null, t => + { + t.HasCheckConstraint("CK_ClassQuiz_QuestionCount", "\"QuestionCount\" BETWEEN 1 AND 200"); + + t.HasCheckConstraint("CK_ClassQuiz_Status", "\"Status\" IN ('Published','Cancelled')"); + + t.HasCheckConstraint("CK_ClassQuiz_TimeLimit", "\"TimeLimitMinutes\" BETWEEN 1 AND 240"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ClassQuizAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("AttemptId") + .HasColumnType("integer"); + + b.Property("CompletedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EnrollmentId") + .HasColumnType("integer"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("QuizId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AttemptId") + .IsUnique() + .HasFilter("\"AttemptId\" IS NOT NULL"); + + b.HasIndex("EnrollmentId"); + + b.HasIndex("LearnerId", "EnrollmentId"); + + b.HasIndex("QuizId", "LearnerId") + .IsUnique(); + + b.ToTable("ClassQuizAssignments", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortComplaint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("CourseSessionId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DecidedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DecidedById") + .HasColumnType("integer"); + + b.Property("Decision") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorAccessGrantedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("MentorDisclosure") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("MentorEvidenceAllowed") + .HasColumnType("boolean"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorRespondedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("MentorResponse") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("RefundReviewRequested") + .HasColumnType("boolean"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("CohortId"); + + b.HasIndex("CourseId"); + + b.HasIndex("CourseSessionId"); + + b.HasIndex("DecidedById"); + + b.HasIndex("LearnerId", "IdempotencyKey") + .IsUnique(); + + b.HasIndex("Status", "CreatedAtUtc"); + + b.HasIndex("MentorId", "Status", "CreatedAtUtc"); + + b.ToTable("CohortComplaints", null, t => + { + t.HasCheckConstraint("CK_CohortComplaint_Category", "\"Category\" IN ('TeachingQuality', 'MentorConduct', 'Schedule', 'PaymentEnrollment', 'Other')"); + + t.HasCheckConstraint("CK_CohortComplaint_Decision", "(\"Status\" NOT IN ('Resolved', 'Rejected') OR (\"Decision\" IS NOT NULL AND length(btrim(\"Decision\")) > 0 AND \"DecidedById\" IS NOT NULL AND \"DecidedAtUtc\" IS NOT NULL))"); + + t.HasCheckConstraint("CK_CohortComplaint_Message", "length(btrim(\"Message\")) BETWEEN 10 AND 2000"); + + t.HasCheckConstraint("CK_CohortComplaint_RefundReview", "NOT \"RefundReviewRequested\" OR \"Category\" = 'PaymentEnrollment'"); + + t.HasCheckConstraint("CK_CohortComplaint_Status", "\"Status\" IN ('Open', 'UnderReview', 'NeedsInformation', 'Resolved', 'Rejected', 'Withdrawn')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortComplaintEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("ActorId") + .HasColumnType("integer"); + + b.Property("ActorRole") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("AtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ComplaintId") + .HasColumnType("integer"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("ComplaintId", "Id"); + + b.ToTable("CohortComplaintEvents", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortEnrollmentEntitlement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConsumedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("ConsumedByCourseId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EntitlementReference") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ExpiresAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("GrantedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("GrantedById") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("PlanId") + .HasColumnType("integer"); + + b.Property("RevocationReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("RevokedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("RevokedById") + .HasColumnType("integer"); + + b.Property("SourceType") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(24) + .HasColumnType("character varying(24)"); + + b.Property("StudyCohortId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EntitlementReference") + .IsUnique(); + + b.HasIndex("LearnerId"); + + b.HasIndex("PlanId"); + + b.HasIndex("StudyCohortId", "LearnerId") + .IsUnique() + .HasFilter("\"Status\" = 'Active' AND \"IsDeleted\" = false"); + + b.ToTable("CohortEnrollmentEntitlements", null, t => + { + t.HasCheckConstraint("CK_CohortEnrollmentEntitlement_NoCredit", "\"SourceType\" NOT IN ('ConsultationCredit', 'Credit1on1', 'OneOnOneCredit')"); + + t.HasCheckConstraint("CK_CohortEnrollmentEntitlement_Status", "\"Status\" IN ('Active', 'Consumed', 'Revoked', 'Expired')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortLearningFeedback", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("CourseSessionId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("RespondedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("RespondedById") + .HasColumnType("integer"); + + b.Property("Response") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("Topic") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("CourseSessionId"); + + b.HasIndex("MentorId"); + + b.HasIndex("RespondedById"); + + b.HasIndex("LearnerId", "IdempotencyKey") + .IsUnique(); + + b.ToTable("CohortLearningFeedback", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortMentorReview", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("Comment") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IsHidden") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("Rating") + .HasColumnType("integer"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CohortId"); + + b.HasIndex("LearnerId"); + + b.HasIndex("CourseId", "MentorId") + .IsUnique(); + + b.HasIndex("MentorId", "IsHidden", "CreatedAtUtc"); + + b.ToTable("CohortMentorReviews", null, t => + { + t.HasCheckConstraint("CK_CohortMentorReview_Rating", "\"Rating\" BETWEEN 1 AND 5"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortScheduleRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CohortRevisionSnapshot") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DecisionNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("ImpactSnapshot") + .IsRequired() + .HasColumnType("text"); + + b.Property("Kind") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("RequestedById") + .HasColumnType("integer"); + + b.Property("RequestedByRole") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ReviewedById") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("ShiftWeeks") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.HasKey("Id"); + + b.HasIndex("CohortId") + .IsUnique() + .HasDatabaseName("IX_CohortScheduleRequests_PendingCohort") + .HasFilter("\"Status\" = 'Pending'"); + + b.HasIndex("ReviewedById"); + + b.HasIndex("CohortId", "Id"); + + b.HasIndex("RequestedById", "IdempotencyKey") + .IsUnique(); + + b.HasIndex("Status", "CreatedAtUtc"); + + b.ToTable("CohortScheduleRequests", null, t => + { + t.HasCheckConstraint("CK_CohortScheduleRequest_Decision", "(\"Status\" NOT IN ('Approved', 'Rejected') OR (\"ReviewedById\" IS NOT NULL AND \"ReviewedAtUtc\" IS NOT NULL)) AND (\"Status\" <> 'Rejected' OR (\"DecisionNote\" IS NOT NULL AND length(btrim(\"DecisionNote\")) > 0))"); + + t.HasCheckConstraint("CK_CohortScheduleRequest_Kind", "\"Kind\" IN ('ShiftWeeks', 'CancelEmptyCohort')"); + + t.HasCheckConstraint("CK_CohortScheduleRequest_Reason", "length(btrim(\"Reason\")) BETWEEN 10 AND 1000"); + + t.HasCheckConstraint("CK_CohortScheduleRequest_ShiftWeeks", "(\"Kind\" = 'ShiftWeeks' AND \"ShiftWeeks\" BETWEEN 1 AND 8) OR (\"Kind\" = 'CancelEmptyCohort' AND \"ShiftWeeks\" IS NULL)"); + + t.HasCheckConstraint("CK_CohortScheduleRequest_Status", "\"Status\" IN ('Pending', 'Approved', 'Rejected', 'Withdrawn')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortScheduleRequestEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("ActorId") + .HasColumnType("integer"); + + b.Property("ActorRole") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("AtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RequestId", "Id"); + + b.ToTable("CohortScheduleRequestEvents", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortTransferRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DecisionNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("DestinationCourseId") + .HasColumnType("integer"); + + b.Property("EligibilitySnapshot") + .HasColumnType("text"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("PolicyId") + .HasColumnType("integer"); + + b.Property("PolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("RequestedTargetCohortId") + .HasColumnType("integer"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ReviewedById") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SourceCohortId") + .HasColumnType("integer"); + + b.Property("SourceCourseId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("TargetCohortId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DestinationCourseId") + .IsUnique() + .HasFilter("\"DestinationCourseId\" IS NOT NULL"); + + b.HasIndex("PolicyId"); + + b.HasIndex("RequestedTargetCohortId"); + + b.HasIndex("ReviewedById"); + + b.HasIndex("SourceCohortId"); + + b.HasIndex("SourceCourseId") + .IsUnique() + .HasDatabaseName("IX_CohortTransferRequests_PendingSource") + .HasFilter("\"Status\" = 'Pending'"); + + b.HasIndex("TargetCohortId"); + + b.HasIndex("LearnerId", "IdempotencyKey") + .IsUnique(); + + b.HasIndex("Status", "CreatedAtUtc"); + + b.ToTable("CohortTransferRequests", null, t => + { + t.HasCheckConstraint("CK_CohortTransferRequest_Decision", "(\"Status\" <> 'Approved' OR (\"TargetCohortId\" IS NOT NULL AND \"DestinationCourseId\" IS NOT NULL AND \"ReviewedById\" IS NOT NULL)) AND (\"Status\" <> 'Rejected' OR (\"DecisionNote\" IS NOT NULL AND length(btrim(\"DecisionNote\")) > 0 AND \"ReviewedById\" IS NOT NULL))"); + + t.HasCheckConstraint("CK_CohortTransferRequest_Status", "\"Status\" IN ('Pending', 'Approved', 'Rejected', 'Withdrawn')"); + + t.HasCheckConstraint("CK_CohortTransferRequest_Target", "\"TargetCohortId\" IS NULL OR \"TargetCohortId\" <> \"SourceCohortId\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortTransferRequestEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("ActorId") + .HasColumnType("integer"); + + b.Property("ActorRole") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("AtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RequestId", "Id"); + + b.ToTable("CohortTransferRequestEvents", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentAiReview", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentId") + .HasColumnType("integer"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ErrorCount") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IssuesJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("RequestedByUserId") + .HasColumnType("integer"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Summary") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Verdict") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("WarningCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentType", "ContentId", "ReviewedAt"); + + b.ToTable("ContentAiReviews"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentApprovalRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("AiProvenanceJson") + .HasColumnType("jsonb"); + + b.Property("BatchId") + .HasColumnType("uuid"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DiffSummaryJson") + .HasColumnType("text"); + + b.Property("EntityType") + .HasColumnType("integer"); + + b.Property("IdempotencyKey") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LanguageSkillId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PayloadJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReviewHistoryJson") + .HasColumnType("jsonb"); + + b.Property("ReviewNote") + .HasColumnType("text"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedByName") + .HasColumnType("text"); + + b.Property("RightsConfirmed") + .HasColumnType("boolean"); + + b.Property("RightsStatus") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RowKey") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SourceFileName") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("character varying(260)"); + + b.Property("SourceReference") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceRowNumber") + .HasColumnType("integer"); + + b.Property("SourceType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasDefaultValue("ImportExcel"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SubmittedByUserId") + .HasColumnType("integer"); + + b.Property("TargetEntityId") + .HasColumnType("integer"); + + b.Property("ValidationSummaryJson") + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("BatchId"); + + b.HasIndex("SubmittedByUserId"); + + b.HasIndex("EntityType", "Status"); + + b.HasIndex("SubmittedByUserId", "IdempotencyKey") + .IsUnique() + .HasFilter("\"IdempotencyKey\" IS NOT NULL"); + + b.ToTable("ContentApprovalRequests"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentAudioTranscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AttemptCount") + .HasColumnType("integer"); + + b.Property("AudioUrl") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("AudioUrlHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CompletedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("Confidence") + .HasColumnType("double precision"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedByUserId") + .HasColumnType("integer"); + + b.Property("ErrorCode") + .HasMaxLength(80) + .HasColumnType("character varying(80)"); + + b.Property("ErrorMessage") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("LanguageCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("LeaseExpiresAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LeaseId") + .HasColumnType("uuid"); + + b.Property("NextAttemptAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("RawTranscriptJson") + .HasColumnType("jsonb"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("Transcript") + .HasColumnType("text"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("AudioUrlHash") + .IsUnique(); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("Status", "NextAttemptAtUtc", "LeaseExpiresAtUtc"); + + b.ToTable("ContentAudioTranscriptions", null, t => + { + t.HasCheckConstraint("CK_ContentAudioTranscription_Attempts", "\"AttemptCount\" >= 0"); + + t.HasCheckConstraint("CK_ContentAudioTranscription_Language", "\"LanguageCode\" = 'ja-JP'"); + + t.HasCheckConstraint("CK_ContentAudioTranscription_Status", "\"Status\" IN ('Pending', 'Processing', 'Completed', 'Failed')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentBankItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EntityType") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LatestBatchId") + .HasColumnType("uuid"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NaturalKey") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("OwnerUserId") + .HasColumnType("integer"); + + b.Property("PayloadJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TargetEntityId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EntityType", "TargetEntityId"); + + b.HasIndex("OwnerUserId", "EntityType", "NaturalKey") + .IsUnique() + .HasFilter("\"IsDeleted\" = false"); + + b.ToTable("ContentBankItems"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentLevelMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer") + .HasColumnName("CertificationLevelId"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("GrammarPatternId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("KanjiId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("VocabularyId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GrammarPatternId"); + + b.HasIndex("KanjiId"); + + b.HasIndex("VocabularyId"); + + b.HasIndex("CertificateLevelId", "GrammarPatternId") + .IsUnique() + .HasFilter("\"GrammarPatternId\" IS NOT NULL AND \"IsDeleted\" = false"); + + b.HasIndex("CertificateLevelId", "KanjiId") + .IsUnique() + .HasFilter("\"KanjiId\" IS NOT NULL AND \"IsDeleted\" = false"); + + b.HasIndex("CertificateLevelId", "VocabularyId") + .IsUnique() + .HasFilter("\"VocabularyId\" IS NOT NULL AND \"IsDeleted\" = false"); + + b.ToTable("ContentLevelMappings", t => + { + t.HasCheckConstraint("CK_ContentLevelMappings_ExactlyOneContent", "(CASE WHEN \"KanjiId\" IS NOT NULL THEN 1 ELSE 0 END) + (CASE WHEN \"VocabularyId\" IS NOT NULL THEN 1 ELSE 0 END) + (CASE WHEN \"GrammarPatternId\" IS NOT NULL THEN 1 ELSE 0 END) = 1"); + }); + + b.HasData( + new + { + Id = 920001, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910001 + }, + new + { + Id = 920002, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910002 + }, + new + { + Id = 920003, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910003 + }, + new + { + Id = 920004, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910004 + }, + new + { + Id = 920005, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910005 + }, + new + { + Id = 920006, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910006 + }, + new + { + Id = 920007, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910007 + }, + new + { + Id = 920008, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910008 + }, + new + { + Id = 920009, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910009 + }, + new + { + Id = 920010, + CertificateLevelId = 1, + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KanjiId = 910010 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentPassage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiProvenanceJson") + .HasColumnType("jsonb"); + + b.Property("AudioTranscript") + .HasColumnType("text"); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("ContentFingerprint") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Instructions") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsArchivedVersion") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ListeningSection") + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.Property("MockTestSectionId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ParentPassageId") + .HasColumnType("integer"); + + b.Property("PassageCode") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("character varying(80)"); + + b.Property("PassageIdentity") + .HasColumnType("uuid"); + + b.Property("PassageText") + .HasColumnType("text"); + + b.Property("PlaybackPolicyJson") + .HasColumnType("jsonb"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("SourceReference") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentFingerprint"); + + b.HasIndex("MockTestSectionId"); + + b.HasIndex("PassageIdentity"); + + b.ToTable("ContentPassages"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseAuditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("ActorId") + .HasColumnType("integer"); + + b.Property("At") + .HasColumnType("timestamp without time zone"); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("CourseAuditEntries", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseRetakeRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("EligibilitySnapshot") + .HasColumnType("text"); + + b.Property("EvidenceUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExamDate") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorSupportPlan") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("MentorSupportPlanAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorSupportPlanById") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Response") + .HasColumnType("text"); + + b.Property("ResultPublishedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedById") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("CourseId") + .IsUnique() + .HasFilter("\"Status\" = 'Pending'"); + + b.ToTable("CourseRetakeRequests", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseScheduleRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Kind") + .IsRequired() + .HasColumnType("text"); + + b.Property("Reason") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestedById") + .HasColumnType("integer"); + + b.Property("Response") + .HasColumnType("text"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedById") + .HasColumnType("integer"); + + b.Property("SessionId") + .HasColumnType("integer"); + + b.Property("Status") + .IsConcurrencyToken() + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CourseId", "SessionId") + .IsUnique() + .HasFilter("\"Status\" = 'Pending'"); + + b.ToTable("CourseScheduleRequests", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.EmailVerification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsUsed") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("VerificationCode") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("EmailVerifications"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Feature", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessMode") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasDefaultValue("FREE"); + + b.Property("Category") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasDefaultValue("general"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("character varying(80)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("CreditFeatureKey") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IsCoreFree") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("RoutePrefixesJson") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("Features"); + + b.HasData( + new + { + Id = 1, + AccessMode = "PLAN_REQUIRED", + Category = "self_study", + Code = "LESSONS_CONTENT", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập kho bài học JLPT đầy đủ theo cấp độ kèm nghe hiểu, đọc hiểu và lưu tiến độ.", + IsCoreFree = false, + IsDeleted = false, + Name = "Thư viện bài học JLPT", + RoutePrefixesJson = "[\"/lessons\",\"/lesson-player\",\"/riki/listening\",\"/riki/reading\"]", + SortOrder = 10 + }, + new + { + Id = 2, + AccessMode = "FREE", + Category = "core_tools", + Code = "JAPANESE_LIBRARY", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Tra cứu ngữ pháp, luyện viết Hiragana, Katakana và Kanji theo thứ tự nét miễn phí.", + IsCoreFree = true, + IsDeleted = false, + Name = "Thư viện Kana, Kanji & Ngữ pháp", + RoutePrefixesJson = "[\"/grammar\",\"/kanji-writing\",\"/vocabulary-detail\"]", + SortOrder = 3 + }, + new + { + Id = 3, + AccessMode = "FREE", + Category = "practice_exam", + Code = "PRACTICE_EXERCISES", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Làm bài luyện tập củng cố kỹ năng và bộ đề theo cấp độ JLPT.", + IsCoreFree = false, + IsDeleted = false, + Name = "Bài luyện tập theo kỹ năng", + RoutePrefixesJson = "[\"/lesson-practice\",\"/practice-sets\"]", + SortOrder = 20 + }, + new + { + Id = 4, + AccessMode = "FREE", + Category = "practice_exam", + Code = "MOCK_TESTS", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Luyện đề thi thử JLPT mô phỏng đầy đủ 4 kỹ năng và theo dõi kết quả.", + IsCoreFree = false, + IsDeleted = false, + Name = "Đề thi thử JLPT", + RoutePrefixesJson = "[\"/mock-test\",\"/mock-tests\",\"/exam-result\"]", + SortOrder = 21 + }, + new + { + Id = 5, + AccessMode = "FREE", + Category = "self_study", + Code = "STANDARD_ROADMAP", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Xem lộ trình học JLPT tiêu chuẩn theo mục tiêu, kết quả đánh giá năng lực và tiến độ học.", + IsCoreFree = false, + IsDeleted = false, + Name = "Lộ trình tiêu chuẩn & Tiến độ học", + RoutePrefixesJson = "[\"/roadmap\"]", + SortOrder = 11 + }, + new + { + Id = 6, + AccessMode = "CREDIT_REQUIRED", + Category = "ai_services", + Code = "AI_MOCK_EXPLANATION", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + CreditFeatureKey = "mock_test_explanation", + Description = "Nhận phân tích chi tiết đáp án đề thi thử từ trợ lý AI.", + IsCoreFree = false, + IsDeleted = false, + Name = "Giải thích câu hỏi bằng AI", + SortOrder = 33 + }, + new + { + Id = 7, + AccessMode = "DISABLED", + Category = "mentor_legacy", + Code = "MENTOR_1ON1_LEGACY", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Gói cũ bao gồm 12 buổi ôn luyện trực tiếp 1-1 với Mentor (đã thay bằng lớp học nhóm).", + IsCoreFree = false, + IsDeleted = false, + Name = "12 buổi meeting 1-1 với Mentor", + SortOrder = 90 + }, + new + { + Id = 8, + AccessMode = "DISABLED", + Category = "mentor_legacy", + Code = "MENTOR_ROOM_LEGACY", + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Cấu hình lịch 1-1 cũ (lớp học nhóm dùng cơ chế ghi danh khóa học riêng).", + IsCoreFree = false, + IsDeleted = false, + Name = "Đặt lịch và phòng học trực tuyến", + SortOrder = 91 + }, + new + { + Id = 9, + AccessMode = "FREE", + Category = "core_tools", + Code = "PERSONAL_NOTEBOOK", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Tạo thư mục, tệp ghi chú, trang bài học, highlight và mục đã lưu cá nhân miễn phí.", + IsCoreFree = true, + IsDeleted = false, + Name = "Sổ tay cá nhân & Mini Notebook", + RoutePrefixesJson = "[\"/kanji-notebook\"]", + SortOrder = 1 + }, + new + { + Id = 10, + AccessMode = "FREE", + Category = "core_tools", + Code = "SRS_STUDY", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Ôn thẻ đến hạn, 4 chế độ ôn tự do, quản lý thẻ cá nhân và thư viện thẻ mẫu miễn phí.", + IsCoreFree = true, + IsDeleted = false, + Name = "Ôn tập SRS & Thư viện thẻ mẫu", + RoutePrefixesJson = "[\"/daily-srs\"]", + SortOrder = 2 + }, + new + { + Id = 11, + AccessMode = "FREE", + Category = "practice_exam", + Code = "PLACEMENT_TEST", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Làm bài đánh giá trình độ JLPT đầu vào để xác định cấp độ học phù hợp.", + IsCoreFree = false, + IsDeleted = false, + Name = "Đánh giá năng lực đầu vào", + RoutePrefixesJson = "[\"/placement\"]", + SortOrder = 19 + }, + new + { + Id = 12, + AccessMode = "CREDIT_REQUIRED", + Category = "ai_services", + Code = "AI_LEARNING_PATH", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + CreditFeatureKey = "learning_path", + Description = "Tạo kế hoạch học tập chi tiết theo ngày bằng AI dựa trên điểm đánh giá và ngày thi.", + IsCoreFree = false, + IsDeleted = false, + Name = "Lộ trình học cá nhân hóa bằng AI", + SortOrder = 30 + }, + new + { + Id = 13, + AccessMode = "CREDIT_REQUIRED", + Category = "ai_services", + Code = "AI_SPEAKING", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + CreditFeatureKey = "speaking", + Description = "Thu âm tiếng Nhật và nhận điểm phát âm, ngữ điệu cùng nhận xét chi tiết từ AI.", + IsCoreFree = false, + IsDeleted = false, + Name = "Luyện nói & Chấm phát âm AI", + RoutePrefixesJson = "[\"/riki/speaking\",\"/speech\"]", + SortOrder = 31 + }, + new + { + Id = 14, + AccessMode = "CREDIT_REQUIRED", + Category = "ai_services", + Code = "AI_WRITING", + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + CreditFeatureKey = "writing", + Description = "Viết câu và bài luận tiếng Nhật, nhận sửa lỗi ngữ pháp và chấm điểm từ AI.", + IsCoreFree = false, + IsDeleted = false, + Name = "Luyện viết & Chấm bài luận AI", + RoutePrefixesJson = "[\"/riki/essay\",\"/sentence-studio\"]", + SortOrder = 32 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.GradingResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FeedbackJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("GradedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("HomeworkSubmissionId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OverallScore") + .HasColumnType("double precision"); + + b.Property("PracticeSubmissionId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("HomeworkSubmissionId") + .IsUnique(); + + b.HasIndex("PracticeSubmissionId") + .IsUnique(); + + b.ToTable("GradingResults"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.GrammarPattern", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExampleSentence") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ExampleSentenceMeaning") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Published"); + + b.Property("Structure") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("UnpublishedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UnpublishedReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UsageNotes") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("Title"); + + b.HasIndex("UserAccountId"); + + b.ToTable("GrammarPatterns"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiDraftFeedback") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("AiDraftGeneratedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("AiDraftScore") + .HasColumnType("double precision"); + + b.Property("AiDraftUnavailableReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("AssignmentScope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasDefaultValue("Booking1on1"); + + b.Property("AuthoredDefinitionJson") + .HasColumnType("text"); + + b.Property("CohortAssignmentGroupKey") + .HasColumnType("uuid"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DueAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Instructions") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("MentorFeedback") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorScore") + .HasColumnType("double precision"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Passed") + .HasColumnType("boolean"); + + b.Property("PublishedByMentorId") + .HasColumnType("integer"); + + b.Property("PublishedFeedbackAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("StudyCourseId") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.HasKey("Id"); + + b.HasIndex("MentorBookingId"); + + b.HasIndex("MentorId"); + + b.HasIndex("StudyCourseId"); + + b.HasIndex("CohortId", "LearnerId"); + + b.HasIndex("LearnerId", "DueAt"); + + b.ToTable("HomeworkAssignments"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentAttachment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FileKey") + .HasColumnType("uuid"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("HomeworkAssignmentId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("Kind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SizeBytes") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("StorageReference") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.HasKey("Id"); + + b.HasIndex("FileKey"); + + b.HasIndex("HomeworkAssignmentId"); + + b.ToTable("HomeworkAssignmentAttachments"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentExercise", b => + { + b.Property("HomeworkAssignmentId") + .HasColumnType("integer"); + + b.Property("PracticeExerciseId") + .HasColumnType("integer"); + + b.HasKey("HomeworkAssignmentId", "PracticeExerciseId"); + + b.HasIndex("PracticeExerciseId"); + + b.ToTable("HomeworkAssignmentExercises", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentLesson", b => + { + b.Property("HomeworkAssignmentId") + .HasColumnType("integer"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.HasKey("HomeworkAssignmentId", "LessonId"); + + b.HasIndex("LessonId"); + + b.ToTable("HomeworkAssignmentLessons"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkSubmission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FileUrl") + .HasColumnType("text"); + + b.Property("HomeworkAssignmentId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LastRevisedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PrivateAudioReference") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("PrivateScanReference") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("RevisionCount") + .HasColumnType("integer"); + + b.Property("ScanStorageUrl") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("SelectedOptionsJson") + .HasColumnType("text"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("TextContent") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("HomeworkAssignmentId") + .IsUnique(); + + b.HasIndex("LearnerId"); + + b.HasIndex("LessonId"); + + b.ToTable("HomeworkSubmissions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkSubmissionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FileKey") + .HasColumnType("uuid"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("HomeworkSubmissionId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SizeBytes") + .HasColumnType("bigint"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("StorageReference") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.HasKey("Id"); + + b.HasIndex("FileKey"); + + b.HasIndex("HomeworkSubmissionId"); + + b.ToTable("HomeworkSubmissionFiles"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.JlptExamSchedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ExamDate") + .HasColumnType("date"); + + b.Property("ImportedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Location") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ReviewNote") + .HasColumnType("text"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedById") + .HasColumnType("integer"); + + b.Property("SourceKey") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("SourceUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsConcurrencyToken() + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SourceKey") + .IsUnique(); + + b.ToTable("JlptExamSchedules", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.JlptLevelPayCoefficient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("Coefficient") + .HasPrecision(10, 4) + .HasColumnType("numeric(10,4)"); + + b.Property("ConfiguredByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveUntilUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ConfiguredByAdminId"); + + b.HasIndex("CertificateLevelId", "EffectiveFromUtc") + .IsUnique(); + + b.ToTable("JlptLevelPayCoefficients", t => + { + t.HasCheckConstraint("CK_JlptLevelPayCoefficient_Positive", "\"Coefficient\" > 0"); + + t.HasCheckConstraint("CK_JlptLevelPayCoefficient_Range", "\"EffectiveUntilUtc\" IS NULL OR \"EffectiveUntilUtc\" > \"EffectiveFromUtc\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaCharacter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("Character") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Romaji") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("StrokeCount") + .HasColumnType("integer"); + + b.Property("StrokeOrderImageUrl") + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.HasKey("Id"); + + b.HasIndex("Character", "Type") + .IsUnique(); + + b.ToTable("KanaCharacters"); + + b.HasData( + new + { + Id = 1, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/22/Ja-a.ogg", + Character = "あ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1757), + IsDeleted = false, + Romaji = "a", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 2, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/28/Ja-i.ogg", + Character = "い", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1766), + IsDeleted = false, + Romaji = "i", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 3, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a2/Ja-u.ogg", + Character = "う", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1768), + IsDeleted = false, + Romaji = "u", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 4, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/21/Ja-e.ogg", + Character = "え", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1770), + IsDeleted = false, + Romaji = "e", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 5, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/d/df/Ja-o.ogg", + Character = "お", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1771), + IsDeleted = false, + Romaji = "o", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 6, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2e/Ja-ka.ogg", + Character = "か", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1774), + IsDeleted = false, + Romaji = "ka", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 7, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/87/Ja-ki.ogg", + Character = "き", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1775), + IsDeleted = false, + Romaji = "ki", + StrokeCount = 4, + Type = "Hiragana" + }, + new + { + Id = 8, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a3/Ja-ku.ogg", + Character = "く", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1776), + IsDeleted = false, + Romaji = "ku", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 9, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b3/Ja-ke.ogg", + Character = "け", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1830), + IsDeleted = false, + Romaji = "ke", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 10, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/18/Ja-ko.ogg", + Character = "こ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1832), + IsDeleted = false, + Romaji = "ko", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 11, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a9/Ja-sa.ogg", + Character = "さ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1833), + IsDeleted = false, + Romaji = "sa", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 12, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/80/Ja-shi.ogg", + Character = "し", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1834), + IsDeleted = false, + Romaji = "shi", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 13, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Ja-su.ogg", + Character = "す", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1835), + IsDeleted = false, + Romaji = "su", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 14, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a8/Ja-se.ogg", + Character = "せ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1836), + IsDeleted = false, + Romaji = "se", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 15, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/00/Ja-so.ogg", + Character = "そ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1837), + IsDeleted = false, + Romaji = "so", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 16, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/d/d2/Ja-ta.ogg", + Character = "た", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1838), + IsDeleted = false, + Romaji = "ta", + StrokeCount = 4, + Type = "Hiragana" + }, + new + { + Id = 17, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/3/38/Ja-chi.ogg", + Character = "ち", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1838), + IsDeleted = false, + Romaji = "chi", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 18, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/3/32/Ja-tsu.ogg", + Character = "つ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1840), + IsDeleted = false, + Romaji = "tsu", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 19, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/10/Ja-te.ogg", + Character = "て", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1841), + IsDeleted = false, + Romaji = "te", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 20, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a5/Ja-to.ogg", + Character = "と", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1842), + IsDeleted = false, + Romaji = "to", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 21, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/9/92/Ja-na.ogg", + Character = "な", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1843), + IsDeleted = false, + Romaji = "na", + StrokeCount = 4, + Type = "Hiragana" + }, + new + { + Id = 22, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b7/Ja-ni.ogg", + Character = "に", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1844), + IsDeleted = false, + Romaji = "ni", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 23, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b1/Ja-nu.ogg", + Character = "ぬ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1845), + IsDeleted = false, + Romaji = "nu", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 24, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/86/Ja-ne.ogg", + Character = "ね", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1845), + IsDeleted = false, + Romaji = "ne", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 25, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/54/Ja-no.ogg", + Character = "の", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1846), + IsDeleted = false, + Romaji = "no", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 26, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/08/Ja-ha.ogg", + Character = "は", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1847), + IsDeleted = false, + Romaji = "ha", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 27, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/9/99/Ja-hi.ogg", + Character = "ひ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1848), + IsDeleted = false, + Romaji = "hi", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 28, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/70/Ja-fu.ogg", + Character = "ふ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1849), + IsDeleted = false, + Romaji = "fu", + StrokeCount = 4, + Type = "Hiragana" + }, + new + { + Id = 29, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2a/Ja-he.ogg", + Character = "へ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1849), + IsDeleted = false, + Romaji = "he", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 30, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a4/Ja-ho.ogg", + Character = "ほ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1850), + IsDeleted = false, + Romaji = "ho", + StrokeCount = 4, + Type = "Hiragana" + }, + new + { + Id = 31, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/0d/Ja-ma.ogg", + Character = "ま", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1851), + IsDeleted = false, + Romaji = "ma", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 32, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/16/Ja-mi.ogg", + Character = "み", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1852), + IsDeleted = false, + Romaji = "mi", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 33, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/eb/Ja-mu.ogg", + Character = "む", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1852), + IsDeleted = false, + Romaji = "mu", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 34, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/8b/Ja-me.ogg", + Character = "め", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1913), + IsDeleted = false, + Romaji = "me", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 35, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c1/Ja-mo.ogg", + Character = "も", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1915), + IsDeleted = false, + Romaji = "mo", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 36, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/e8/Ja-ya.ogg", + Character = "や", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1915), + IsDeleted = false, + Romaji = "ya", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 37, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/7b/Ja-yu.ogg", + Character = "ゆ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1916), + IsDeleted = false, + Romaji = "yu", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 38, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c9/Ja-yo.ogg", + Character = "よ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1917), + IsDeleted = false, + Romaji = "yo", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 39, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/04/Ja-ra.ogg", + Character = "ら", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1918), + IsDeleted = false, + Romaji = "ra", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 40, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/76/Ja-ri.ogg", + Character = "り", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1919), + IsDeleted = false, + Romaji = "ri", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 41, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/56/Ja-ru.ogg", + Character = "る", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1920), + IsDeleted = false, + Romaji = "ru", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 42, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/57/Ja-re.ogg", + Character = "れ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1920), + IsDeleted = false, + Romaji = "re", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 43, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/ed/Ja-ro.ogg", + Character = "ろ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1922), + IsDeleted = false, + Romaji = "ro", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 44, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/f/f2/Ja-wa.ogg", + Character = "わ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1922), + IsDeleted = false, + Romaji = "wa", + StrokeCount = 2, + Type = "Hiragana" + }, + new + { + Id = 45, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/77/Ja-wo.ogg", + Character = "を", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1923), + IsDeleted = false, + Romaji = "wo", + StrokeCount = 3, + Type = "Hiragana" + }, + new + { + Id = 46, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/0c/Ja-n.ogg", + Character = "ん", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1924), + IsDeleted = false, + Romaji = "n", + StrokeCount = 1, + Type = "Hiragana" + }, + new + { + Id = 47, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/22/Ja-a.ogg", + Character = "ア", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1955), + IsDeleted = false, + Romaji = "a", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 48, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/28/Ja-i.ogg", + Character = "イ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1958), + IsDeleted = false, + Romaji = "i", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 49, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a2/Ja-u.ogg", + Character = "ウ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1959), + IsDeleted = false, + Romaji = "u", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 50, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/21/Ja-e.ogg", + Character = "エ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1960), + IsDeleted = false, + Romaji = "e", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 51, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/d/df/Ja-o.ogg", + Character = "オ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1961), + IsDeleted = false, + Romaji = "o", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 52, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2e/Ja-ka.ogg", + Character = "カ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1961), + IsDeleted = false, + Romaji = "ka", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 53, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/87/Ja-ki.ogg", + Character = "キ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1962), + IsDeleted = false, + Romaji = "ki", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 54, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a3/Ja-ku.ogg", + Character = "ク", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1963), + IsDeleted = false, + Romaji = "ku", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 55, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b3/Ja-ke.ogg", + Character = "ケ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(1964), + IsDeleted = false, + Romaji = "ke", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 56, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/18/Ja-ko.ogg", + Character = "コ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2006), + IsDeleted = false, + Romaji = "ko", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 57, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a9/Ja-sa.ogg", + Character = "サ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2009), + IsDeleted = false, + Romaji = "sa", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 58, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/80/Ja-shi.ogg", + Character = "シ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2010), + IsDeleted = false, + Romaji = "shi", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 59, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Ja-su.ogg", + Character = "ス", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2011), + IsDeleted = false, + Romaji = "su", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 60, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a8/Ja-se.ogg", + Character = "セ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2012), + IsDeleted = false, + Romaji = "se", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 61, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/00/Ja-so.ogg", + Character = "ソ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2014), + IsDeleted = false, + Romaji = "so", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 62, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/d/d2/Ja-ta.ogg", + Character = "タ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2015), + IsDeleted = false, + Romaji = "ta", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 63, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/3/38/Ja-chi.ogg", + Character = "チ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2016), + IsDeleted = false, + Romaji = "chi", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 64, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/3/32/Ja-tsu.ogg", + Character = "ツ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2017), + IsDeleted = false, + Romaji = "tsu", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 65, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/10/Ja-te.ogg", + Character = "テ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2019), + IsDeleted = false, + Romaji = "te", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 66, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a5/Ja-to.ogg", + Character = "ト", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2022), + IsDeleted = false, + Romaji = "to", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 67, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/9/92/Ja-na.ogg", + Character = "ナ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2023), + IsDeleted = false, + Romaji = "na", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 68, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b7/Ja-ni.ogg", + Character = "ニ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2024), + IsDeleted = false, + Romaji = "ni", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 69, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b1/Ja-nu.ogg", + Character = "ヌ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2026), + IsDeleted = false, + Romaji = "nu", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 70, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/86/Ja-ne.ogg", + Character = "ネ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2027), + IsDeleted = false, + Romaji = "ne", + StrokeCount = 4, + Type = "Katakana" + }, + new + { + Id = 71, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/54/Ja-no.ogg", + Character = "ノ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2028), + IsDeleted = false, + Romaji = "no", + StrokeCount = 1, + Type = "Katakana" + }, + new + { + Id = 72, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/08/Ja-ha.ogg", + Character = "ハ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2029), + IsDeleted = false, + Romaji = "ha", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 73, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/9/99/Ja-hi.ogg", + Character = "ヒ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2030), + IsDeleted = false, + Romaji = "hi", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 74, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/70/Ja-fu.ogg", + Character = "フ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2032), + IsDeleted = false, + Romaji = "fu", + StrokeCount = 1, + Type = "Katakana" + }, + new + { + Id = 75, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2a/Ja-he.ogg", + Character = "ヘ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2033), + IsDeleted = false, + Romaji = "he", + StrokeCount = 1, + Type = "Katakana" + }, + new + { + Id = 76, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a4/Ja-ho.ogg", + Character = "ホ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2034), + IsDeleted = false, + Romaji = "ho", + StrokeCount = 4, + Type = "Katakana" + }, + new + { + Id = 77, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/0d/Ja-ma.ogg", + Character = "マ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2036), + IsDeleted = false, + Romaji = "ma", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 78, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/1/16/Ja-mi.ogg", + Character = "ミ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2037), + IsDeleted = false, + Romaji = "mi", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 79, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/eb/Ja-mu.ogg", + Character = "ム", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2038), + IsDeleted = false, + Romaji = "mu", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 80, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/8/8b/Ja-me.ogg", + Character = "メ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2039), + IsDeleted = false, + Romaji = "me", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 81, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c1/Ja-mo.ogg", + Character = "モ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2086), + IsDeleted = false, + Romaji = "mo", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 82, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/e8/Ja-ya.ogg", + Character = "ヤ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2087), + IsDeleted = false, + Romaji = "ya", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 83, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/7b/Ja-yu.ogg", + Character = "ユ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2088), + IsDeleted = false, + Romaji = "yu", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 84, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c9/Ja-yo.ogg", + Character = "ヨ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2089), + IsDeleted = false, + Romaji = "yo", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 85, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/04/Ja-ra.ogg", + Character = "ラ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2090), + IsDeleted = false, + Romaji = "ra", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 86, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/76/Ja-ri.ogg", + Character = "リ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2092), + IsDeleted = false, + Romaji = "ri", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 87, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/56/Ja-ru.ogg", + Character = "ル", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2093), + IsDeleted = false, + Romaji = "ru", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 88, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/5/57/Ja-re.ogg", + Character = "レ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2094), + IsDeleted = false, + Romaji = "re", + StrokeCount = 1, + Type = "Katakana" + }, + new + { + Id = 89, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/e/ed/Ja-ro.ogg", + Character = "ロ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2096), + IsDeleted = false, + Romaji = "ro", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 90, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/f/f2/Ja-wa.ogg", + Character = "ワ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2097), + IsDeleted = false, + Romaji = "wa", + StrokeCount = 2, + Type = "Katakana" + }, + new + { + Id = 91, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/7/77/Ja-wo.ogg", + Character = "ヲ", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2098), + IsDeleted = false, + Romaji = "wo", + StrokeCount = 3, + Type = "Katakana" + }, + new + { + Id = 92, + AudioUrl = "https://upload.wikimedia.org/wikipedia/commons/0/0c/Ja-n.ogg", + Character = "ン", + CreatedDate = new DateTime(2026, 10, 26, 16, 6, 11, 768, DateTimeKind.Utc).AddTicks(2099), + IsDeleted = false, + Romaji = "n", + StrokeCount = 2, + Type = "Katakana" + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaWritingPracticeCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EaseFactor") + .HasColumnType("double precision"); + + b.Property("IntervalDays") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("KanaCharacterId") + .HasColumnType("integer"); + + b.Property("LastReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NextReviewDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Repetitions") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("KanaCharacterId"); + + b.HasIndex("UserId", "KanaCharacterId") + .IsUnique(); + + b.HasIndex("UserId", "NextReviewDate"); + + b.ToTable("KanaWritingPracticeCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaWritingPracticeHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("KanaWritingPracticeCardId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Quality") + .HasColumnType("integer"); + + b.Property("Rating") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("TotalMistakes") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("KanaWritingPracticeCardId"); + + b.ToTable("KanaWritingPracticeHistories"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Kanji", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("Character") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("KunYomi") + .HasColumnType("text"); + + b.Property("Meaning") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OnYomi") + .HasColumnType("text"); + + b.Property("SinoVietnamese") + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Published"); + + b.Property("StrokeCount") + .HasColumnType("integer"); + + b.Property("StrokeOrderImageUrl") + .HasColumnType("text"); + + b.Property("UnpublishedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UnpublishedReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.HasKey("Id"); + + b.HasIndex("Character"); + + b.HasIndex("Status"); + + b.HasIndex("UserAccountId"); + + b.ToTable("Kanjis"); + + b.HasData( + new + { + Id = 910001, + Character = "日", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "ひ、か", + Meaning = "Mặt trời; ngày", + OnYomi = "ニチ、ジツ", + SinoVietnamese = "Nhật", + Status = "Published", + StrokeCount = 4, + Version = 1 + }, + new + { + Id = 910002, + Character = "月", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "つき", + Meaning = "Mặt trăng; tháng", + OnYomi = "ゲツ、ガツ", + SinoVietnamese = "Nguyệt", + Status = "Published", + StrokeCount = 4, + Version = 1 + }, + new + { + Id = 910003, + Character = "火", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "ひ、ほ", + Meaning = "Lửa", + OnYomi = "カ", + SinoVietnamese = "Hỏa", + Status = "Published", + StrokeCount = 4, + Version = 1 + }, + new + { + Id = 910004, + Character = "水", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "みず", + Meaning = "Nước", + OnYomi = "スイ", + SinoVietnamese = "Thủy", + Status = "Published", + StrokeCount = 4, + Version = 1 + }, + new + { + Id = 910005, + Character = "木", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "き、こ", + Meaning = "Cây; gỗ", + OnYomi = "モク、ボク", + SinoVietnamese = "Mộc", + Status = "Published", + StrokeCount = 4, + Version = 1 + }, + new + { + Id = 910006, + Character = "金", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "かね、かな", + Meaning = "Vàng; tiền", + OnYomi = "キン、コン", + SinoVietnamese = "Kim", + Status = "Published", + StrokeCount = 8, + Version = 1 + }, + new + { + Id = 910007, + Character = "土", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "つち", + Meaning = "Đất", + OnYomi = "ド、ト", + SinoVietnamese = "Thổ", + Status = "Published", + StrokeCount = 3, + Version = 1 + }, + new + { + Id = 910008, + Character = "山", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "やま", + Meaning = "Núi", + OnYomi = "サン", + SinoVietnamese = "Sơn", + Status = "Published", + StrokeCount = 3, + Version = 1 + }, + new + { + Id = 910009, + Character = "川", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "かわ", + Meaning = "Sông", + OnYomi = "セン", + SinoVietnamese = "Xuyên", + Status = "Published", + StrokeCount = 3, + Version = 1 + }, + new + { + Id = 910010, + Character = "人", + CreatedDate = new DateTime(2026, 10, 3, 0, 0, 0, 0, DateTimeKind.Utc), + IsDeleted = false, + KunYomi = "ひと", + Meaning = "Người", + OnYomi = "ジン、ニン", + SinoVietnamese = "Nhân", + Status = "Published", + StrokeCount = 2, + Version = 1 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LanguageSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique() + .HasFilter("\"Code\" IS NOT NULL"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("LanguageSkills"); + + b.HasData( + new + { + Id = 1, + Code = "VOCABULARY", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese vocabulary learning skill.", + IsDeleted = false, + Name = "Vocabulary" + }, + new + { + Id = 2, + Code = "KANJI", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese kanji learning skill.", + IsDeleted = false, + Name = "Kanji" + }, + new + { + Id = 3, + Code = "GRAMMAR", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese grammar learning skill.", + IsDeleted = false, + Name = "Grammar" + }, + new + { + Id = 4, + Code = "LISTENING", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese listening comprehension skill.", + IsDeleted = false, + Name = "Listening" + }, + new + { + Id = 5, + Code = "READING", + CreatedDate = new DateTime(2026, 9, 29, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Japanese reading comprehension skill.", + IsDeleted = false, + Name = "Reading" + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerEssay", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentText") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ImageStoragePath") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ImageUrl") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OcrLanguage") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("OriginalOcrText") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "CreatedDate"); + + b.ToTable("LearnerEssays"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerFeedback", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("Rating") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TargetTitle") + .IsRequired() + .HasColumnType("text"); + + b.Property("TargetType") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("UpdatedAtUtc", "Id"); + + b.HasIndex("LearnerId", "TargetType", "TargetId") + .IsUnique(); + + b.ToTable("LearnerFeedback", null, t => + { + t.HasCheckConstraint("CK_LearnerFeedback_Rating", "\"Rating\" BETWEEN 1 AND 5"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerHighlight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnchorPrefix") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("AnchorSuffix") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Color") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ContentVersionHash") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EndOffset") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LinkedNoteEntryId") + .HasColumnType("integer"); + + b.Property("LinkedReviewCardId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("SelectedText") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("SourcePath") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceTitle") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("StartOffset") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TargetKey") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TargetType") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("TranslationSnapshot") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LinkedNoteEntryId"); + + b.HasIndex("LinkedReviewCardId"); + + b.HasIndex("UserId", "CreatedDate"); + + b.HasIndex("UserId", "TargetKey"); + + b.HasIndex("UserId", "TargetType", "TargetId"); + + b.ToTable("LearnerHighlights"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FolderId") + .HasColumnType("integer"); + + b.Property("IsDefault") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FolderId"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_LearnerNotes_UserId_IsDefault") + .HasFilter("\"IsDeleted\" = false AND \"IsDefault\" = true"); + + b.HasIndex("UserId", "Name"); + + b.HasIndex("UserId", "FolderId", "IsDeleted", "SortOrder"); + + b.ToTable("LearnerNotes"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNoteEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContextSnippet") + .HasMaxLength(600) + .HasColumnType("character varying(600)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExampleMeaning") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ExampleSentence") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("GrammarPatternId") + .HasColumnType("integer"); + + b.Property("HighlightColor") + .HasMaxLength(24) + .HasColumnType("character varying(24)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsFavorite") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("ItemKind") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasDefaultValue("manual"); + + b.Property("KanjiId") + .HasColumnType("integer") + .HasColumnName("KanjiEntryId"); + + b.Property("LearnerNoteId") + .HasColumnType("integer") + .HasColumnName("VocabularyListId"); + + b.Property("ManualMeaning") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ManualReading") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ManualWord") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Note") + .HasColumnType("text"); + + b.Property("NotebookPageId") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("SourceId") + .HasColumnType("integer"); + + b.Property("SourcePath") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceTitle") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SourceType") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("TagsJson") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValueSql("'[]'::jsonb"); + + b.Property("VocabularyId") + .HasColumnType("integer") + .HasColumnName("VocabularyEntryId"); + + b.HasKey("Id"); + + b.HasIndex("GrammarPatternId"); + + b.HasIndex("KanjiId"); + + b.HasIndex("VocabularyId"); + + b.HasIndex("LearnerNoteId", "IsDeleted"); + + b.HasIndex("NotebookPageId", "IsDeleted", "SortOrder"); + + b.ToTable("LearnerNoteEntries"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerPracticeAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsCorrect") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PracticeExerciseAttemptId") + .HasColumnType("integer"); + + b.Property("PracticeQuestionId") + .HasColumnType("integer"); + + b.Property("SelectedOptionId") + .HasColumnType("integer"); + + b.Property("TextAnswer") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("PracticeQuestionId"); + + b.HasIndex("SelectedOptionId"); + + b.HasIndex("PracticeExerciseAttemptId", "PracticeQuestionId") + .IsUnique(); + + b.ToTable("LearnerPracticeAnswers"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("CertificateLevelId") + .HasColumnType("integer") + .HasColumnName("CertificationLevelId"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("EstimatedMinutes") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(15); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LanguageSkillId") + .HasColumnType("integer") + .HasColumnName("SkillId"); + + b.Property("LearningObjectives") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PrerequisiteLessonId") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("SourceProvenance") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Published"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("TopicId") + .HasColumnType("integer"); + + b.Property("UnpublishedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UnpublishedReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.HasKey("Id"); + + b.HasIndex("LanguageSkillId"); + + b.HasIndex("PrerequisiteLessonId"); + + b.HasIndex("Status"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserAccountId"); + + b.HasIndex("CertificateLevelId", "LanguageSkillId"); + + b.ToTable("Lessons"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonGrammar", b => + { + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("GrammarPatternId") + .HasColumnType("integer") + .HasColumnName("GrammarPointId"); + + b.HasKey("LessonId", "GrammarPatternId"); + + b.HasIndex("GrammarPatternId"); + + b.ToTable("LessonGrammars"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonKanji", b => + { + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("KanjiId") + .HasColumnType("integer") + .HasColumnName("KanjiEntryId"); + + b.HasKey("LessonId", "KanjiId"); + + b.HasIndex("KanjiId"); + + b.ToTable("LessonKanjis"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonProgress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CompletedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FirstViewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("InteractionCount") + .HasColumnType("integer"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LastInteractedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("LastPositionSeconds") + .HasColumnType("integer"); + + b.Property("LastWatchedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ProgressPercent") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.HasIndex("UserId", "LessonId") + .IsUnique(); + + b.ToTable("LessonProgresses"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonVocabulary", b => + { + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("VocabularyId") + .HasColumnType("integer") + .HasColumnName("VocabularyEntryId"); + + b.HasKey("LessonId", "VocabularyId"); + + b.HasIndex("VocabularyId"); + + b.ToTable("LessonVocabularies"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAbuseReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdminNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("ReporterId") + .HasColumnType("integer"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedByAdminId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("TargetUserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("MentorBookingId"); + + b.HasIndex("ReporterId") + .HasDatabaseName("IX_MentorAbuseReports_ReporterId"); + + b.HasIndex("Status") + .HasDatabaseName("IX_MentorAbuseReports_Status"); + + b.HasIndex("TargetUserId") + .HasDatabaseName("IX_MentorAbuseReports_TargetUserId"); + + b.ToTable("MentorAbuseReports", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAttendanceApproval", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedEligibleMinutes") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DecisionReason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("EvidenceSummary") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("RawLearnerDurationSeconds") + .HasColumnType("integer"); + + b.Property("RawMentorDurationSeconds") + .HasColumnType("integer"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ReviewedByAdminId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("MentorBookingId") + .IsUnique(); + + b.HasIndex("ReviewedByAdminId"); + + b.ToTable("MentorAttendanceApprovals", t => + { + t.HasCheckConstraint("CK_MentorAttendanceApproval_Minutes", "\"ApprovedEligibleMinutes\" IS NULL OR (\"ApprovedEligibleMinutes\" > 0 AND \"ApprovedEligibleMinutes\" <= 90)"); + + t.HasCheckConstraint("CK_MentorAttendanceApproval_RawDuration", "\"RawMentorDurationSeconds\" >= 0 AND \"RawLearnerDurationSeconds\" >= 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAttendanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseSessionId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("FirstJoinedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LastJoinedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LastSeenAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LeftAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("ReconnectionCount") + .HasColumnType("integer"); + + b.Property("Role") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("RoomId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TotalDurationSeconds") + .HasColumnType("integer"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CourseSessionId"); + + b.HasIndex("RoomId") + .HasDatabaseName("IX_MentorAttendanceRecords_RoomId"); + + b.HasIndex("Status") + .HasDatabaseName("IX_MentorAttendanceRecords_Status"); + + b.HasIndex("UserId") + .HasDatabaseName("IX_MentorAttendanceRecords_UserId"); + + b.HasIndex("MentorBookingId", "UserId") + .IsUnique() + .HasDatabaseName("IX_MentorAttendanceRecords_Booking_User"); + + b.HasIndex("RoomId", "UserId") + .IsUnique() + .HasFilter("\"MentorBookingId\" IS NULL"); + + b.ToTable("MentorAttendanceRecords", null, t => + { + t.HasCheckConstraint("CK_MentorAttendanceRecord_Duration", "\"TotalDurationSeconds\" >= 0"); + + t.HasCheckConstraint("CK_MentorAttendanceRecord_Reconnection", "\"ReconnectionCount\" >= 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAvailability", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdminName") + .HasColumnType("text"); + + b.Property("AttendanceTrackingEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("BookedCount") + .HasColumnType("integer"); + + b.Property("CancelReason") + .HasColumnType("text"); + + b.Property("CancelRejectedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CancelRejectionReason") + .HasColumnType("text"); + + b.Property("CancelRequestedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ChangeRequestReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ChangeRequestedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ChangeResolution") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp without time zone"); + + b.Property("GenerationKey") + .HasMaxLength(160) + .HasColumnType("character varying(160)"); + + b.Property("GroupPolicyId") + .HasColumnType("integer"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LocalBusinessDate") + .HasColumnType("date"); + + b.Property("MaxLearners") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorScheduleRuleId") + .HasColumnType("bigint"); + + b.Property("MentorWeeklyAvailabilityId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PolicyVersion") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RejectedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RejectionReason") + .HasColumnType("text"); + + b.Property("RestMinutesSnapshot") + .HasColumnType("integer"); + + b.Property("RoomId") + .HasColumnType("uuid"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("bytea"); + + b.Property("SessionMinutesSnapshot") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp without time zone"); + + b.Property("TeachingProposalId") + .HasColumnType("integer"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("GenerationKey") + .IsUnique() + .HasFilter("\"GenerationKey\" IS NOT NULL"); + + b.HasIndex("GroupPolicyId"); + + b.HasIndex("MentorScheduleRuleId"); + + b.HasIndex("MentorWeeklyAvailabilityId"); + + b.HasIndex("RoomId") + .IsUnique(); + + b.HasIndex("TeachingProposalId") + .HasFilter("\"TeachingProposalId\" IS NOT NULL"); + + b.HasIndex("MentorId", "StartTime", "EndTime"); + + b.ToTable("MentorAvailabilities", t => + { + t.HasCheckConstraint("CK_MentorAvailability_BookedCount", "\"BookedCount\" >= 0 AND \"BookedCount\" <= \"MaxLearners\""); + + t.HasCheckConstraint("CK_MentorAvailability_GeneratedSlot", "(\"GenerationKey\" IS NULL AND \"PolicyVersion\" IS NULL AND \"MentorScheduleRuleId\" IS NULL AND \"LocalBusinessDate\" IS NULL AND \"GroupPolicyId\" IS NULL AND \"SessionMinutesSnapshot\" IS NULL AND \"RestMinutesSnapshot\" IS NULL) OR (\"GenerationKey\" IS NOT NULL AND \"PolicyVersion\" IS NOT NULL AND \"PolicyVersion\" > 0 AND (\"MentorScheduleRuleId\" IS NOT NULL OR \"TeachingProposalId\" IS NOT NULL) AND \"LocalBusinessDate\" IS NOT NULL AND ((\"GroupPolicyId\" IS NULL AND \"SessionMinutesSnapshot\" IS NULL AND \"RestMinutesSnapshot\" IS NULL AND \"MaxLearners\" = 1 AND \"EndTime\" = \"StartTime\" + INTERVAL '90 minutes') OR (\"GroupPolicyId\" IS NOT NULL AND \"SessionMinutesSnapshot\" > 0 AND \"RestMinutesSnapshot\" >= 0 AND \"MaxLearners\" BETWEEN 1 AND 50 AND \"EndTime\" = \"StartTime\" + \"SessionMinutesSnapshot\" * INTERVAL '1 minute')))"); + }); + + b.HasData( + new + { + Id = 990001, + AdminName = "Seed Demo", + AttendanceTrackingEnabled = true, + BookedCount = 1, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndTime = new DateTime(2026, 10, 2, 10, 0, 0, 0, DateTimeKind.Unspecified), + IsApproved = true, + IsDeleted = false, + MaxLearners = 4, + MentorId = 900002, + RoomId = new Guid("a1000000-0000-0000-0000-000000990001"), + StartTime = new DateTime(2026, 10, 2, 9, 0, 0, 0, DateTimeKind.Unspecified), + Version = 0u + }, + new + { + Id = 990002, + AdminName = "Seed Demo", + AttendanceTrackingEnabled = true, + BookedCount = 0, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndTime = new DateTime(2026, 10, 3, 14, 0, 0, 0, DateTimeKind.Unspecified), + IsApproved = true, + IsDeleted = false, + MaxLearners = 4, + MentorId = 900002, + RoomId = new Guid("a1000000-0000-0000-0000-000000990002"), + StartTime = new DateTime(2026, 10, 3, 13, 0, 0, 0, DateTimeKind.Unspecified), + Version = 0u + }, + new + { + Id = 990003, + AdminName = "Seed Demo", + AttendanceTrackingEnabled = true, + BookedCount = 0, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndTime = new DateTime(2026, 10, 4, 10, 0, 0, 0, DateTimeKind.Unspecified), + IsApproved = true, + IsDeleted = false, + MaxLearners = 4, + MentorId = 900003, + RoomId = new Guid("a1000000-0000-0000-0000-000000990003"), + StartTime = new DateTime(2026, 10, 4, 9, 0, 0, 0, DateTimeKind.Unspecified), + Version = 0u + }, + new + { + Id = 990004, + AdminName = "Seed Demo", + AttendanceTrackingEnabled = true, + BookedCount = 0, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndTime = new DateTime(2026, 10, 5, 14, 0, 0, 0, DateTimeKind.Unspecified), + IsApproved = true, + IsDeleted = false, + MaxLearners = 4, + MentorId = 900003, + RoomId = new Guid("a1000000-0000-0000-0000-000000990004"), + StartTime = new DateTime(2026, 10, 5, 13, 0, 0, 0, DateTimeKind.Unspecified), + Version = 0u + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountHolderName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("AccountNumberHash") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AccountVersion") + .HasColumnType("integer"); + + b.Property("BankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BankName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveUntilUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EncryptedAccountNumber") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsCurrent") + .HasColumnType("boolean"); + + b.Property("MaskedAccountNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.Property("VerificationNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("VerificationStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("VerifiedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("VerifiedByAdminId") + .HasColumnType("integer"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("MentorUserId") + .IsUnique() + .HasDatabaseName("IX_MentorBankAccounts_MentorUserId_Current") + .HasFilter("\"IsCurrent\" = TRUE"); + + b.HasIndex("VerifiedByAdminId"); + + b.HasIndex("MentorUserId", "AccountVersion") + .IsUnique(); + + b.ToTable("MentorBankAccounts", t => + { + t.HasCheckConstraint("CK_MentorBankAccount_Version", "\"AccountVersion\" >= 1"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBooking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AttendedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CancellationReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("CancelledAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("CancelledByRole") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CancelledByUserId") + .HasColumnType("integer"); + + b.Property("CompensationCurrency") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("CompensationFormulaVersion") + .HasColumnType("integer"); + + b.Property("CompensationLevelId") + .HasColumnType("integer"); + + b.Property("CompletedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("CreditGrantId") + .HasColumnType("bigint"); + + b.Property("ExceptionApproved") + .HasColumnType("boolean"); + + b.Property("ExceptionReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ExceptionRequested") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("FrozenHourlyRate") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("FrozenLevelCoefficient") + .HasPrecision(10, 4) + .HasColumnType("numeric(10,4)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MeetingLink") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("MentorAvailabilityId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PracticeFeedback") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("PracticeFeedbackAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PracticeScore") + .HasColumnType("integer"); + + b.Property("Question") + .HasColumnType("text"); + + b.Property("ScheduledAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ScheduledCompensationAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("UserSubscriptionId") + .HasColumnType("integer"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("CompensationLevelId"); + + b.HasIndex("CreditGrantId"); + + b.HasIndex("MentorAvailabilityId", "LearnerId") + .IsUnique() + .HasFilter("\"MentorAvailabilityId\" IS NOT NULL AND \"LearnerId\" IS NOT NULL AND NOT \"IsDeleted\" AND \"Status\" <> 'Cancelled'"); + + b.HasIndex("MentorAvailabilityId", "UserSubscriptionId") + .IsUnique() + .HasFilter("NOT \"IsDeleted\" AND \"Status\" <> 'Cancelled'"); + + b.HasIndex("UserSubscriptionId", "Status"); + + b.ToTable("MentorBookings"); + + b.HasData( + new + { + Id = 990001, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + ExceptionRequested = false, + IsDeleted = false, + MeetingLink = "http://localhost:5173/mentor-meeting/a1000000-0000-0000-0000-000000990001", + MentorAvailabilityId = 990001, + Question = "Meeting demo để kiểm thử phòng họp trên frontend.", + ScheduledAt = new DateTime(2026, 10, 2, 9, 0, 0, 0, DateTimeKind.Unspecified), + Status = "Assigned", + UserSubscriptionId = 990001, + Version = 0u + }, + new + { + Id = 990002, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + ExceptionRequested = false, + IsDeleted = false, + MeetingLink = "http://localhost:5173/mentor-meeting/a1000000-0000-0000-0000-000000990001", + MentorAvailabilityId = 990001, + Question = "Em muốn nhờ Mentor giải đáp phần ngữ pháp N3 bài 5.", + ScheduledAt = new DateTime(2026, 10, 2, 9, 0, 0, 0, DateTimeKind.Unspecified), + Status = "Assigned", + UserSubscriptionId = 990002, + Version = 0u + }, + new + { + Id = 990003, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + ExceptionRequested = false, + IsDeleted = false, + MeetingLink = "http://localhost:5173/mentor-meeting/a1000000-0000-0000-0000-000000990001", + MentorAvailabilityId = 990001, + Question = "Hỏi về cách phân biệt giữa ~てくる và ~ていく.", + ScheduledAt = new DateTime(2026, 10, 2, 9, 0, 0, 0, DateTimeKind.Unspecified), + Status = "Assigned", + UserSubscriptionId = 990003, + Version = 0u + }, + new + { + Id = 990004, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + ExceptionRequested = false, + IsDeleted = false, + MeetingLink = "http://localhost:5173/mentor-meeting/a1000000-0000-0000-0000-000000990001", + MentorAvailabilityId = 990001, + Question = "Tư vấn phương pháp luyện nghe JLPT N3 hiệu quả.", + ScheduledAt = new DateTime(2026, 10, 2, 9, 0, 0, 0, DateTimeKind.Unspecified), + Status = "Assigned", + UserSubscriptionId = 990004, + Version = 0u + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingDayGuard", b => + { + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("LocalBusinessDate") + .HasColumnType("date"); + + b.Property("ActiveBookingCount") + .HasColumnType("integer"); + + b.HasKey("MentorId", "LocalBusinessDate"); + + b.ToTable("MentorBookingDayGuards", null, t => + { + t.HasCheckConstraint("CK_MentorBookingDayGuard_Count", "\"ActiveBookingCount\" >= 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingIntent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IntentKey") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("RequestHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("MentorBookingId"); + + b.HasIndex("LearnerId", "IntentKey") + .IsUnique(); + + b.ToTable("MentorBookingIntents", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingReservation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EndUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("LocalBusinessDate") + .HasColumnType("date"); + + b.Property("MentorAvailabilityId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("PolicyVersion") + .HasColumnType("integer"); + + b.Property("ReleasedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("RestProtectedUntilUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("StartUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("MentorAvailabilityId") + .HasFilter("\"ReleasedAtUtc\" IS NULL"); + + b.HasIndex("MentorBookingId") + .IsUnique(); + + b.HasIndex("MentorAvailabilityId", "MentorId"); + + b.HasIndex("MentorId", "LocalBusinessDate", "ReleasedAtUtc"); + + b.ToTable("MentorBookingReservations", null, t => + { + t.HasCheckConstraint("CK_MentorBookingReservation_Interval", "\"EndUtc\" > \"StartUtc\""); + + t.HasCheckConstraint("CK_MentorBookingReservation_PolicyVersion", "\"PolicyVersion\" > 0"); + + t.HasCheckConstraint("CK_MentorBookingReservation_Rest", "\"RestProtectedUntilUtc\" >= \"EndUtc\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingTerms", b => + { + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("ConfirmedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("MentorAvailabilityId") + .HasColumnType("integer"); + + b.Property("PolicyVersion") + .HasColumnType("integer"); + + b.Property("ScheduledEndUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ScheduledStartUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("MentorBookingId"); + + b.HasIndex("MentorAvailabilityId"); + + b.ToTable("MentorBookingTerms", null, t => + { + t.HasCheckConstraint("CK_MentorBookingTerms_Interval", "\"ScheduledEndUtc\" > \"ScheduledStartUtc\""); + + t.HasCheckConstraint("CK_MentorBookingTerms_PolicyVersion", "\"PolicyVersion\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCalendarConnection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastSyncedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("ProtectedRefreshToken") + .HasColumnType("text"); + + b.Property("StateExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("StateHash") + .HasColumnType("text"); + + b.Property("SyncedEventsJson") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MentorId") + .IsUnique(); + + b.HasIndex("StateHash") + .IsUnique(); + + b.ToTable("MentorCalendarConnections", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ReadAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SenderUserId") + .HasColumnType("integer"); + + b.Property("SentAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.HasKey("Id"); + + b.HasIndex("SenderUserId"); + + b.HasIndex("MentorBookingId", "Id"); + + b.HasIndex("MentorBookingId", "ReadAt", "SenderUserId"); + + b.ToTable("MentorChatMessages"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCreditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreditGrantId") + .HasColumnType("bigint"); + + b.Property("EntryType") + .HasColumnType("integer"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("OperationKey") + .IsRequired() + .HasMaxLength(160) + .HasColumnType("character varying(160)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("LearnerId"); + + b.HasIndex("OperationKey") + .IsUnique(); + + b.HasIndex("CreditGrantId", "EntryType"); + + b.HasIndex("MentorBookingId", "EntryType"); + + b.ToTable("MentorCreditEntries", null, t => + { + t.HasCheckConstraint("CK_MentorCreditEntry_Amount", "\"Amount\" <> 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCreditGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AvailableQuantity") + .HasColumnType("integer"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("InitialQuantity") + .HasColumnType("integer"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("PolicyVersion") + .HasColumnType("integer"); + + b.Property("UserSubscriptionId") + .HasColumnType("integer"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("UserSubscriptionId") + .IsUnique(); + + b.HasIndex("LearnerId", "ExpiresAtUtc"); + + b.HasIndex("LearnerId", "CertificateLevelId", "ExpiresAtUtc"); + + b.ToTable("MentorCreditGrants", null, t => + { + t.HasCheckConstraint("CK_MentorCreditGrant_PolicyVersion", "\"PolicyVersion\" > 0"); + + t.HasCheckConstraint("CK_MentorCreditGrant_Quantity", "\"InitialQuantity\" > 0 AND \"AvailableQuantity\" >= 0 AND \"AvailableQuantity\" <= \"InitialQuantity\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorDispute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdminDecision") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("AdminNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Category") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("CreditRefunded") + .HasColumnType("boolean"); + + b.Property("EvidenceUrls") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("IsRefundApproved") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorRespondedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorResponse") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("RefundOperationKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ResolvedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("ResolvedByAdminId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("LearnerId") + .HasDatabaseName("IX_MentorDisputes_LearnerId"); + + b.HasIndex("MentorBookingId") + .HasDatabaseName("IX_MentorDisputes_MentorBookingId"); + + b.HasIndex("MentorId") + .HasDatabaseName("IX_MentorDisputes_MentorId"); + + b.HasIndex("ResolvedByAdminId"); + + b.HasIndex("Status") + .HasDatabaseName("IX_MentorDisputes_Status"); + + b.ToTable("MentorDisputes", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorDisputeHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ActorId") + .HasColumnType("integer"); + + b.Property("ActorRole") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("DisputeId") + .HasColumnType("integer"); + + b.Property("NewStatus") + .HasColumnType("integer"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PreviousStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DisputeId") + .HasDatabaseName("IX_MentorDisputeHistories_DisputeId"); + + b.ToTable("MentorDisputeHistories", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorEarningEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedEligibleMinutes") + .HasColumnType("integer"); + + b.Property("AttendanceApprovalId") + .HasColumnType("bigint"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByAdminId") + .HasColumnType("integer"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("FormulaVersion") + .HasColumnType("integer"); + + b.Property("FrozenHourlyRate") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("FrozenLevelCoefficient") + .HasPrecision(10, 4) + .HasColumnType("numeric(10,4)"); + + b.Property("GrossAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("JlptLevelCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.Property("OperationKey") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("PayrollPeriodId") + .HasColumnType("bigint"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("AttendanceApprovalId") + .IsUnique(); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("CreatedByAdminId"); + + b.HasIndex("MentorBookingId") + .IsUnique(); + + b.HasIndex("OperationKey") + .IsUnique(); + + b.HasIndex("PayrollPeriodId"); + + b.HasIndex("MentorUserId", "Status"); + + b.ToTable("MentorEarningEntries", t => + { + t.HasCheckConstraint("CK_MentorEarningEntry_Positive", "\"FrozenHourlyRate\" > 0 AND \"FrozenLevelCoefficient\" > 0 AND \"ApprovedEligibleMinutes\" > 0 AND \"ApprovedEligibleMinutes\" <= 90 AND \"GrossAmount\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorGroupPolicy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CancellationLeadHours") + .HasColumnType("integer"); + + b.Property("CheckoutHoldMinutes") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByAdminId") + .HasColumnType("integer"); + + b.Property("DeletedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedByAdminId") + .HasColumnType("integer"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("HomeworkDeadlineDays") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsArchivedRevision") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("KpiReportingPeriodDays") + .HasColumnType("integer"); + + b.Property("LastAppliedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("LastAppliedByAdminId") + .HasColumnType("integer"); + + b.Property("LearnerTransferEnabled") + .HasColumnType("boolean"); + + b.Property("MaxLearners") + .HasColumnType("integer"); + + b.Property("MentorReplacementEnabled") + .HasColumnType("boolean"); + + b.Property("MentorReplacementLeadHours") + .HasColumnType("integer"); + + b.Property("MinimumPreparationDays") + .HasColumnType("integer"); + + b.Property("MinimumPublishedEnrollmentDays") + .HasColumnType("integer"); + + b.Property("PlacementAttemptLimit") + .HasColumnType("integer"); + + b.Property("RemediationAttendanceThresholdPercent") + .ValueGeneratedOnAdd() + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)") + .HasDefaultValue(90m); + + b.Property("RemediationCompletionThresholdPercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("RemediationThresholdComparison") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.Property("RequireAdminRemediationReview") + .HasColumnType("boolean"); + + b.Property("RequireOfficialExamEvidence") + .HasColumnType("boolean"); + + b.Property("ReschedulingLeadHours") + .HasColumnType("integer"); + + b.Property("RestMinutes") + .HasColumnType("integer"); + + b.Property("RetakeSupportEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SessionMinutes") + .HasColumnType("integer"); + + b.Property("TransferAllowedAfterSourceStart") + .HasColumnType("boolean"); + + b.Property("TuitionPerSessionN2") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("TuitionPerSessionN3") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("TuitionPerSessionN4") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("TuitionPerSessionN5") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedByAdminId") + .HasColumnType("integer"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByAdminId"); + + b.HasIndex("DeletedByAdminId"); + + b.HasIndex("EffectiveFromUtc"); + + b.HasIndex("IsActive") + .IsUnique() + .HasDatabaseName("IX_MentorGroupPolicies_SingleActive") + .HasFilter("\"IsActive\" = TRUE"); + + b.HasIndex("LastAppliedByAdminId"); + + b.HasIndex("UpdatedByAdminId"); + + b.HasIndex("Version") + .IsUnique() + .HasDatabaseName("IX_MentorGroupPolicies_LiveVersion") + .HasFilter("\"IsArchivedRevision\" = FALSE"); + + b.ToTable("MentorGroupPolicies", null, t => + { + t.HasCheckConstraint("CK_MentorGroupPolicy_Capacity", "\"MaxLearners\" BETWEEN 1 AND 50"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_CheckoutHold", "\"CheckoutHoldMinutes\" BETWEEN 1 AND 60"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_Comparison", "\"RemediationThresholdComparison\" IN ('>', '>=')"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_EnrollmentDays", "\"MinimumPublishedEnrollmentDays\" BETWEEN 1 AND 180"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_Evidence", "\"RequireOfficialExamEvidence\" AND \"RequireAdminRemediationReview\""); + + t.HasCheckConstraint("CK_MentorGroupPolicy_Positive", "\"Version\" > 0 AND \"SessionMinutes\" > 0 AND \"RestMinutes\" >= 0 AND \"MinimumPreparationDays\" >= 1 AND \"CancellationLeadHours\" >= 0 AND \"ReschedulingLeadHours\" >= 0 AND \"HomeworkDeadlineDays\" > 0 AND \"PlacementAttemptLimit\" > 0 AND \"KpiReportingPeriodDays\" > 0"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_Remediation", "\"RemediationCompletionThresholdPercent\" > 0 AND \"RemediationCompletionThresholdPercent\" <= 100"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_RemediationAttendance", "\"RemediationAttendanceThresholdPercent\" > 0 AND \"RemediationAttendanceThresholdPercent\" <= 100"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_ReplacementLead", "\"MentorReplacementLeadHours\" BETWEEN 0 AND 720"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_State", "\"Revision\" > 0 AND NOT (\"IsActive\" AND (\"IsArchivedRevision\" OR \"IsDeleted\"))"); + + t.HasCheckConstraint("CK_MentorGroupPolicy_TransferAfterStart", "\"LearnerTransferEnabled\" OR NOT \"TransferAllowedAfterSourceStart\""); + + t.HasCheckConstraint("CK_MentorGroupPolicy_Tuition", "\"TuitionPerSessionN5\" >= 0 AND \"TuitionPerSessionN4\" >= 0 AND \"TuitionPerSessionN3\" >= 0 AND \"TuitionPerSessionN2\" >= 0"); + }); + + b.HasData( + new + { + Id = 1, + CancellationLeadHours = 24, + CheckoutHoldMinutes = 10, + CreatedAtUtc = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + EffectiveFromUtc = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + HomeworkDeadlineDays = 7, + IsActive = true, + IsArchivedRevision = false, + IsDeleted = false, + KpiReportingPeriodDays = 30, + LastAppliedAtUtc = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + LearnerTransferEnabled = true, + MaxLearners = 4, + MentorReplacementEnabled = true, + MentorReplacementLeadHours = 24, + MinimumPreparationDays = 1, + MinimumPublishedEnrollmentDays = 7, + PlacementAttemptLimit = 2, + RemediationAttendanceThresholdPercent = 90m, + RemediationCompletionThresholdPercent = 90m, + RemediationThresholdComparison = ">", + RequireAdminRemediationReview = true, + RequireOfficialExamEvidence = true, + ReschedulingLeadHours = 24, + RestMinutes = 15, + RetakeSupportEnabled = true, + Revision = 1, + SessionMinutes = 90, + TransferAllowedAfterSourceStart = false, + TuitionPerSessionN2 = 110000m, + TuitionPerSessionN3 = 90000m, + TuitionPerSessionN4 = 75000m, + TuitionPerSessionN5 = 60000m, + Version = 1 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorHourlyRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AmountPerHour") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ConfiguredByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveUntilUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ConfiguredByAdminId"); + + b.HasIndex("MentorUserId", "EffectiveFromUtc") + .IsUnique(); + + b.ToTable("MentorHourlyRates", t => + { + t.HasCheckConstraint("CK_MentorHourlyRate_Positive", "\"AmountPerHour\" > 0"); + + t.HasCheckConstraint("CK_MentorHourlyRate_Range", "\"EffectiveUntilUtc\" IS NULL OR \"EffectiveUntilUtc\" > \"EffectiveFromUtc\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorKpiPolicy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AverageRatingTarget") + .HasPrecision(3, 2) + .HasColumnType("numeric(3,2)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByAdminId") + .HasColumnType("integer"); + + b.Property("DeletedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedByAdminId") + .HasColumnType("integer"); + + b.Property("EffectiveFromMonth") + .HasColumnType("date"); + + b.Property("GradingCompletionTargetPercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("HomeworkMinimumCount") + .HasColumnType("integer"); + + b.Property("HomeworkPerSessionCount") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MinimumPresencePercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("OnTimeResponseTargetPercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("PositiveReviewTargetPercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("ResponseSlaHours") + .HasColumnType("integer"); + + b.Property("TeachingCompletionTargetPercent") + .HasPrecision(5, 2) + .HasColumnType("numeric(5,2)"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByAdminId"); + + b.HasIndex("EffectiveFromMonth") + .IsUnique() + .HasFilter("\"IsDeleted\" = FALSE"); + + b.HasIndex("Version") + .IsUnique(); + + b.ToTable("MentorKpiPolicies", null, t => + { + t.HasCheckConstraint("CK_MentorKpiPolicy_Homework", "\"HomeworkMinimumCount\" >= 0 AND \"HomeworkPerSessionCount\" > 0"); + + t.HasCheckConstraint("CK_MentorKpiPolicy_Month", "EXTRACT(DAY FROM \"EffectiveFromMonth\") = 1"); + + t.HasCheckConstraint("CK_MentorKpiPolicy_Percents", "\"MinimumPresencePercent\" > 0 AND \"MinimumPresencePercent\" <= 100 AND \"TeachingCompletionTargetPercent\" > 0 AND \"TeachingCompletionTargetPercent\" <= 100 AND \"GradingCompletionTargetPercent\" > 0 AND \"GradingCompletionTargetPercent\" <= 100 AND \"OnTimeResponseTargetPercent\" > 0 AND \"OnTimeResponseTargetPercent\" <= 100 AND \"PositiveReviewTargetPercent\" > 0 AND \"PositiveReviewTargetPercent\" <= 100"); + + t.HasCheckConstraint("CK_MentorKpiPolicy_Rating", "\"AverageRatingTarget\" >= 1 AND \"AverageRatingTarget\" <= 5"); + + t.HasCheckConstraint("CK_MentorKpiPolicy_Sla", "\"ResponseSlaHours\" > 0"); + }); + + b.HasData( + new + { + Id = 1, + AverageRatingTarget = 4m, + CreatedAtUtc = new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + EffectiveFromMonth = new DateOnly(2026, 1, 1), + GradingCompletionTargetPercent = 90m, + HomeworkMinimumCount = 1, + HomeworkPerSessionCount = 2, + IsDeleted = false, + MinimumPresencePercent = 80m, + Note = "Phiên bản khởi tạo", + OnTimeResponseTargetPercent = 90m, + PositiveReviewTargetPercent = 80m, + ResponseSlaHours = 24, + TeachingCompletionTargetPercent = 90m, + Version = 1 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorOutboxEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AggregateId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("AggregateType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Attempts") + .HasColumnType("integer"); + + b.Property("AvailableAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DeliveredAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EventKey") + .IsRequired() + .HasMaxLength(160) + .HasColumnType("character varying(160)"); + + b.Property("EventType") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("character varying(80)"); + + b.Property("EventVersion") + .HasColumnType("integer"); + + b.Property("PayloadJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("EventKey") + .IsUnique(); + + b.HasIndex("DeliveredAtUtc", "AvailableAtUtc", "CreatedAtUtc"); + + b.ToTable("MentorOutboxEvents", null, t => + { + t.HasCheckConstraint("CK_MentorOutbox_Attempts", "\"Attempts\" >= 0"); + + t.HasCheckConstraint("CK_MentorOutbox_EventVersion", "\"EventVersion\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayoutAttempt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("AttemptNumber") + .HasColumnType("integer"); + + b.Property("BatchId") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("CompletedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ConfirmedByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("ErrorCode") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ErrorMessage") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("EvidenceNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("EvidenceStorageKey") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ExecutionMethod") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("IdempotencyKey") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("InitiatedByAdminId") + .HasColumnType("integer"); + + b.Property("InternalStatus") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("LockedBankAccountId") + .HasColumnType("bigint"); + + b.Property("PayoutObligationId") + .HasColumnType("bigint"); + + b.Property("ProviderPayoutId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ProviderStatus") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("TransferReference") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("ConfirmedByAdminId"); + + b.HasIndex("IdempotencyKey") + .IsUnique(); + + b.HasIndex("InitiatedByAdminId"); + + b.HasIndex("LockedBankAccountId"); + + b.HasIndex("PayoutObligationId") + .IsUnique() + .HasDatabaseName("IX_MentorPayoutAttempts_OneSucceededPerObligation") + .HasFilter("\"InternalStatus\" = 'Succeeded'"); + + b.HasIndex("TransferReference") + .IsUnique() + .HasDatabaseName("IX_MentorPayoutAttempts_SucceededTransferReference") + .HasFilter("\"TransferReference\" IS NOT NULL AND \"InternalStatus\" = 'Succeeded'"); + + b.HasIndex("PayoutObligationId", "AttemptNumber") + .IsUnique(); + + b.ToTable("MentorPayoutAttempts", t => + { + t.HasCheckConstraint("CK_MentorPayoutAttempt_ManualEvidence", "(\"ExecutionMethod\" <> 'ManualBankTransfer' OR \"InternalStatus\" <> 'Succeeded') OR (\"TransferReference\" IS NOT NULL AND \"EvidenceStorageKey\" IS NOT NULL)"); + + t.HasCheckConstraint("CK_MentorPayoutAttempt_Positive", "\"Amount\" > 0 AND \"AttemptNumber\" >= 1"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayoutObligation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveAttemptId") + .HasColumnType("bigint"); + + b.Property("ApprovedByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("LockedBankAccountId") + .HasColumnType("bigint"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.Property("OrganizationPayoutAccountId") + .HasColumnType("bigint"); + + b.Property("PayableAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("PayrollPeriodId") + .HasColumnType("bigint"); + + b.Property("SelectedMethod") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("SettledAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("SettledAttemptId") + .HasColumnType("bigint"); + + b.Property("SettledReference") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedByAdminId"); + + b.HasIndex("LockedBankAccountId"); + + b.HasIndex("MentorUserId"); + + b.HasIndex("OrganizationPayoutAccountId"); + + b.HasIndex("PayrollPeriodId") + .IsUnique(); + + b.ToTable("MentorPayoutObligations", t => + { + t.HasCheckConstraint("CK_MentorPayoutObligation_Positive", "\"PayableAmount\" > 0"); + + t.HasCheckConstraint("CK_MentorPayoutObligation_Settlement", "(\"Status\" <> 'Paid') OR (\"SettledAttemptId\" IS NOT NULL AND \"SettledReference\" IS NOT NULL AND \"SettledAtUtc\" IS NOT NULL)"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("OperationKey") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("PayrollPeriodId") + .HasColumnType("bigint"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("RelatedBookingId") + .HasColumnType("integer"); + + b.Property("RelatedEarningEntryId") + .HasColumnType("bigint"); + + b.Property("SignedAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedByAdminId"); + + b.HasIndex("OperationKey") + .IsUnique(); + + b.HasIndex("PayrollPeriodId"); + + b.ToTable("MentorPayrollAdjustments", t => + { + t.HasCheckConstraint("CK_MentorPayrollAdjustment_NonZero", "\"SignedAmount\" <> 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovedEligibleMinutes") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EarningEntryId") + .HasColumnType("bigint"); + + b.Property("FrozenHourlyRate") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("FrozenLevelCoefficient") + .HasPrecision(10, 4) + .HasColumnType("numeric(10,4)"); + + b.Property("LineAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("PayrollPeriodId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("EarningEntryId") + .IsUnique(); + + b.HasIndex("MentorBookingId") + .IsUnique(); + + b.HasIndex("PayrollPeriodId"); + + b.ToTable("MentorPayrollLines", t => + { + t.HasCheckConstraint("CK_MentorPayrollLine_Positive", "\"LineAmount\" > 0 AND \"ApprovedEligibleMinutes\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApprovalNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ApprovedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByAdminId") + .HasColumnType("integer"); + + b.Property("ClosedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("GrossPayableAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.Property("Month") + .HasColumnType("integer"); + + b.Property("PreparedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("PreparedByAdminId") + .HasColumnType("integer"); + + b.Property("SequenceNumber") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("SupplementalReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("TotalAdjustmentsAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("TotalEarningsAmount") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("Year") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ApprovedByAdminId"); + + b.HasIndex("PreparedByAdminId"); + + b.HasIndex("MentorUserId", "Year", "Month", "SequenceNumber", "Currency") + .IsUnique(); + + b.ToTable("MentorPayrollPeriods", t => + { + t.HasCheckConstraint("CK_MentorPayrollPeriod_Payable", "\"TotalEarningsAmount\" >= 0 AND \"GrossPayableAmount\" >= 0"); + + t.HasCheckConstraint("CK_MentorPayrollPeriod_Period", "\"Year\" >= 2020 AND \"Year\" <= 2100 AND \"Month\" >= 1 AND \"Month\" <= 12 AND \"SequenceNumber\" >= 1"); + + t.HasCheckConstraint("CK_MentorPayrollPeriod_Supplemental", "\"SequenceNumber\" = 1 OR (\"SupplementalReason\" IS NOT NULL AND length(trim(\"SupplementalReason\")) > 0)"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorProfile", b => + { + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("Bio") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Expertise") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("IntroductionVideoUrl") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("JlptLevel") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("RejectionReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ReviewNotes") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedByAdminName") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("VerificationDocumentUrl") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("VerificationStatus") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Workplace") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("YearsOfExperience") + .HasColumnType("integer"); + + b.HasKey("MentorId"); + + b.ToTable("MentorProfiles", (string)null); + + b.HasData( + new + { + MentorId = 900002, + Bio = "Chuyên gia tiếng Nhật với 8 năm kinh nghiệm giảng dạy JLPT N1, N2 và tiếng Nhật doanh nghiệp.", + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + Expertise = "Luyện thi JLPT N1-N2, Tiếng Nhật thương mại, Phỏng vấn xin việc", + IsDeleted = false, + JlptLevel = "N1", + ReviewedAt = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + ReviewedByAdminName = "Admin System", + SubmittedAt = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + VerificationStatus = "Approved", + Workplace = "Riki Nihongo Academy", + YearsOfExperience = 8 + }, + new + { + MentorId = 900003, + Bio = "Giảng viên tiếng Nhật bản xứ, chuyên sâu về phát âm và giao tiếp Kaiwa thực tế.", + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + Expertise = "Giao tiếp Kaiwa tự nhiên, Luyện phát âm chuẩn Tokyo, JLPT N3-N2", + IsDeleted = false, + JlptLevel = "N1", + ReviewedAt = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + ReviewedByAdminName = "Admin System", + SubmittedAt = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + VerificationStatus = "Approved", + Workplace = "Riki Nihongo Academy", + YearsOfExperience = 5 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorReview", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("IsPublic") + .HasColumnType("boolean"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorRepliedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorReply") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ModerationStatus") + .HasColumnType("integer"); + + b.Property("Rating") + .HasColumnType("integer"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("LearnerId") + .HasDatabaseName("IX_MentorReviews_LearnerId"); + + b.HasIndex("MentorBookingId") + .IsUnique() + .HasDatabaseName("IX_MentorReviews_MentorBookingId"); + + b.HasIndex("MentorId", "IsPublic", "ModerationStatus") + .HasDatabaseName("IX_MentorReviews_Mentor_Public_Status"); + + b.ToTable("MentorReviews", null, t => + { + t.HasCheckConstraint("CK_MentorReview_Rating_Range", "\"Rating\" >= 1 AND \"Rating\" <= 5"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorSchedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoPublish") + .HasColumnType("boolean"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFrom") + .HasColumnType("date"); + + b.Property("GeneratedThrough") + .HasColumnType("date"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("PolicyVersion") + .HasColumnType("integer"); + + b.Property("TimeZoneId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("MentorId", "PolicyVersion") + .IsUnique(); + + b.ToTable("MentorSchedules", null, t => + { + t.HasCheckConstraint("CK_MentorSchedule_PolicyVersion", "\"PolicyVersion\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorScheduleRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DaypartCode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("EffectiveFrom") + .HasColumnType("date"); + + b.Property("EffectiveTo") + .HasColumnType("date"); + + b.Property("LocalEnd") + .HasColumnType("time without time zone"); + + b.Property("LocalStart") + .HasColumnType("time without time zone"); + + b.Property("ScheduleId") + .HasColumnType("bigint"); + + b.Property("Weekday") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ScheduleId", "Weekday", "DaypartCode", "EffectiveFrom") + .IsUnique(); + + b.ToTable("MentorScheduleRules", null, t => + { + t.HasCheckConstraint("CK_MentorScheduleRule_Daypart", "\"DaypartCode\" IN ('Morning', 'Noon', 'Afternoon', 'Evening')"); + + t.HasCheckConstraint("CK_MentorScheduleRule_Time", "\"LocalEnd\" > \"LocalStart\""); + + t.HasCheckConstraint("CK_MentorScheduleRule_Weekday", "\"Weekday\" BETWEEN 0 AND 6"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingProposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CourseDurationWeeks") + .HasColumnType("integer"); + + b.Property("CourseObjective") + .HasMaxLength(1500) + .HasColumnType("character varying(1500)"); + + b.Property("CoursePlanId") + .HasColumnType("integer"); + + b.Property("CourseTitle") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpectedStartDate") + .HasColumnType("date"); + + b.Property("GroupPolicyId") + .HasColumnType("integer"); + + b.Property("HiddenFromMentorAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IsHiddenFromMentorHistory") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("LastSavedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("OpenEnrollmentIdempotencyKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("OpenedClassAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("OptionalAttachmentsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("OptionalNotes") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("PolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("ProgramType") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ReviewReason") + .HasMaxLength(1500) + .HasColumnType("character varying(1500)"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ReviewedByAdminId") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SessionDurationMinutes") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("SubmissionIdempotencyKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("SubmittedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("WeeklySessionsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("CoursePlanId"); + + b.HasIndex("GroupPolicyId"); + + b.HasIndex("ReviewedByAdminId"); + + b.HasIndex("MentorId", "OpenEnrollmentIdempotencyKey") + .IsUnique() + .HasDatabaseName("IX_MentorTeachingProposals_MentorId_OpenEnrollmentIdempotencyKey") + .HasFilter("\"OpenEnrollmentIdempotencyKey\" IS NOT NULL"); + + b.HasIndex("MentorId", "SubmissionIdempotencyKey") + .IsUnique() + .HasDatabaseName("IX_MentorTeachingProposals_MentorId_SubmissionIdempotencyKey") + .HasFilter("\"SubmissionIdempotencyKey\" IS NOT NULL"); + + b.HasIndex("Status", "SubmittedAtUtc"); + + b.HasIndex("MentorId", "Status", "UpdatedAtUtc"); + + b.ToTable("MentorTeachingProposals", null, t => + { + t.HasCheckConstraint("CK_MentorTeachingProposal_Duration", "\"CourseDurationWeeks\" BETWEEN 1 AND 104 AND \"SessionDurationMinutes\" BETWEEN 30 AND 240"); + + t.HasCheckConstraint("CK_MentorTeachingProposal_ProgramType", "\"ProgramType\" IN ('StandardJlpt', 'IntensiveJlpt', 'ExamPrepJlpt', 'CustomJlpt')"); + + t.HasCheckConstraint("CK_MentorTeachingProposal_Revision", "\"Revision\" > 0"); + + t.HasCheckConstraint("CK_MentorTeachingProposal_Status", "\"Status\" IN ('Draft', 'PendingReview', 'ChangesRequested', 'Approved', 'OpenedClass', 'Rejected', 'Withdrawn')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingProposalEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasMaxLength(48) + .HasColumnType("character varying(48)"); + + b.Property("ActorRole") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ActorUserId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("FromStatus") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("Reason") + .HasMaxLength(1500) + .HasColumnType("character varying(1500)"); + + b.Property("RevisionAfter") + .HasColumnType("integer"); + + b.Property("SnapshotJson") + .HasColumnType("jsonb"); + + b.Property("ToStatus") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.HasKey("Id"); + + b.HasIndex("ProposalId", "CreatedAtUtc"); + + b.ToTable("MentorTeachingProposalEvents", null, t => + { + t.HasCheckConstraint("CK_MentorTeachingProposalEvent_RevisionAfter", "\"RevisionAfter\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingQualification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("MentorUserId") + .HasColumnType("integer"); + + b.Property("RevokedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("VerifiedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("VerifiedByAdminId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("VerifiedByAdminId"); + + b.HasIndex("MentorUserId", "CertificateLevelId") + .IsUnique() + .HasFilter("\"IsActive\" = TRUE"); + + b.ToTable("MentorTeachingQualifications", t => + { + t.HasCheckConstraint("CK_MentorTeachingQualification_Revoked", "\"RevokedAtUtc\" IS NULL OR \"RevokedAtUtc\" >= \"VerifiedAtUtc\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTimesheetAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdminId") + .HasColumnType("integer"); + + b.Property("CohortSessionId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Evidence") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("NewConfirmedMinutes") + .HasColumnType("integer"); + + b.Property("NewStatus") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("PreviousConfirmedMinutes") + .HasColumnType("integer"); + + b.Property("PreviousStatus") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.HasIndex("CohortSessionId", "CreatedAtUtc"); + + b.ToTable("MentorTimesheetAdjustments", null, t => + { + t.HasCheckConstraint("CK_MentorTimesheetAdjustment_Minutes", "\"NewConfirmedMinutes\" >= 0 AND \"PreviousConfirmedMinutes\" >= 0"); + + t.HasCheckConstraint("CK_MentorTimesheetAdjustment_Status", "\"NewStatus\" IN ('Taught', 'Absent')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorWeeklyAvailability", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Period") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("MentorId", "Date", "Period") + .IsUnique() + .HasFilter("NOT \"IsDeleted\""); + + b.ToTable("MentorWeeklyAvailabilities", t => + { + t.HasCheckConstraint("CK_MentorWeeklyAvailability_Period", "\"Period\" IN ('Morning', 'Afternoon', 'Evening')"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiProvenanceJson") + .HasColumnType("jsonb"); + + b.Property("AnswerKeyJson") + .HasColumnType("jsonb"); + + b.Property("AudioTranscript") + .HasColumnType("text"); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("ContentFingerprint") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Difficulty") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("Explanation") + .HasColumnType("text"); + + b.Property("GroupSortOrder") + .HasColumnType("integer"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("InteractionDataJson") + .HasColumnType("jsonb"); + + b.Property("IsArchivedVersion") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MockTestSectionId") + .HasColumnType("integer") + .HasColumnName("PracticeTestSectionId"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OptionsJson") + .HasColumnType("jsonb"); + + b.Property("ParentQuestionId") + .HasColumnType("integer"); + + b.Property("PassageId") + .HasColumnType("integer"); + + b.Property("PlaybackPolicyJson") + .HasColumnType("jsonb"); + + b.Property("QuestionGroupTitle") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("QuestionIdentity") + .HasColumnType("uuid"); + + b.Property("QuestionText") + .IsRequired() + .HasColumnType("text"); + + b.Property("QuestionType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasDefaultValue("SingleChoice"); + + b.Property("QuestionVersion") + .HasColumnType("integer"); + + b.Property("SkillMetadataJson") + .HasColumnType("jsonb"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("SourceReference") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasDefaultValue("Manual"); + + b.Property("TagsJson") + .HasColumnType("jsonb"); + + b.Property("TemplateKind") + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.Property("Topic") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.HasKey("Id"); + + b.HasIndex("ContentFingerprint"); + + b.HasIndex("PassageId"); + + b.HasIndex("QuestionIdentity"); + + b.HasIndex("MockTestSectionId", "IsArchivedVersion"); + + b.ToTable("MockQuestions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestionOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Explanation") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsCorrect") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MockQuestionId") + .HasColumnType("integer") + .HasColumnName("PracticeQuestionId"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OptionText") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("MockQuestionId"); + + b.ToTable("MockQuestionOptions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiProvenanceJson") + .HasColumnType("jsonb"); + + b.Property("BlueprintPolicyJson") + .HasColumnType("jsonb"); + + b.Property("CertificateLevelId") + .HasColumnType("integer") + .HasColumnName("CertificationLevelId"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("ExamKind") + .HasColumnType("integer"); + + b.Property("FocusSkillId") + .HasColumnType("integer"); + + b.Property("IncludedSkillsJson") + .HasColumnType("jsonb"); + + b.Property("IsArchivedVersion") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsManagedWorkflow") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ParentExamId") + .HasColumnType("integer"); + + b.Property("SourceReference") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceType") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("TagsJson") + .HasColumnType("jsonb"); + + b.Property("TimeLimitMinutes") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("UserAccountId"); + + b.ToTable("MockTests"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiExplanationGeneratedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("AiExplanationInputJson") + .HasColumnType("jsonb"); + + b.Property("AiExplanationJson") + .HasColumnType("jsonb"); + + b.Property("AiExplanationVersion") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsCorrect") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MockQuestionId") + .HasColumnType("integer") + .HasColumnName("PracticeQuestionId"); + + b.Property("MockTestAttemptId") + .HasColumnType("integer") + .HasColumnName("PracticeTestAttemptId"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ResponseJson") + .HasColumnType("jsonb"); + + b.Property("SelectedOptionId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("MockQuestionId"); + + b.HasIndex("SelectedOptionId"); + + b.HasIndex("MockTestAttemptId", "MockQuestionId") + .IsUnique(); + + b.ToTable("MockTestAnswers"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestAttempt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AttemptKind") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsPlacementAssessment") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("QuestionSnapshotJson") + .HasColumnType("text"); + + b.Property("StartedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("TotalScore") + .HasColumnType("double precision"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StartedAt"); + + b.HasIndex("UserAccountId"); + + b.HasIndex("UserId"); + + b.HasIndex("UserId", "AttemptKind") + .IsUnique() + .HasFilter("\"AttemptKind\" = 1 AND \"IsCompleted\" = false AND \"IsDeleted\" = false"); + + b.ToTable("MockTestAttempts"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateSectionId") + .HasColumnType("integer") + .HasColumnName("CertificationSectionId"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DurationMinutes") + .HasColumnType("integer"); + + b.Property("Instructions") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LanguageSkillId") + .HasColumnType("integer") + .HasColumnName("SkillId"); + + b.Property("MockTestId") + .HasColumnType("integer") + .HasColumnName("MockTestId"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SectionPolicyJson") + .HasColumnType("jsonb"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("CertificateSectionId"); + + b.HasIndex("LanguageSkillId"); + + b.HasIndex("MockTestId", "CertificateSectionId"); + + b.ToTable("MockTestSections"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestSectionResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CorrectCount") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MockTestAttemptId") + .HasColumnType("integer") + .HasColumnName("MockTestAttemptId"); + + b.Property("MockTestSectionId") + .HasColumnType("integer") + .HasColumnName("MockTestSectionId"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ScorePercent") + .HasColumnType("double precision"); + + b.Property("TotalCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("MockTestSectionId"); + + b.HasIndex("MockTestAttemptId", "MockTestSectionId") + .IsUnique(); + + b.ToTable("MockTestSectionResults"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Note", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnsweredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("AuthorRole") + .IsRequired() + .HasColumnType("text"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MentorBookingId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("MentorBookingId") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("Notes"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookFolder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDefault") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_NotebookFolders_UserId_IsDefault") + .HasFilter("\"IsDeleted\" = false AND \"IsDefault\" = true"); + + b.HasIndex("UserId", "NormalizedName") + .IsUnique() + .HasFilter("\"IsDeleted\" = false"); + + b.HasIndex("UserId", "IsDeleted", "SortOrder"); + + b.ToTable("NotebookFolders", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookPage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChecklistCompletedCount") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("ChecklistTotalCount") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("ContentFormatVersion") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("ContentJson") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValueSql("'{\"type\":\"doc\",\"version\":1,\"blocks\":[]}'::jsonb"); + + b.Property("ContentPlainText") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue(""); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FavoritedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDefault") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsFavorite") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("LastAutosavedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LearnerNoteId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("SourceId") + .HasColumnType("integer"); + + b.Property("SourcePath") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceTitle") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SourceType") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("IX_NotebookPages_UserId_IsDefault") + .HasFilter("\"IsDeleted\" = false AND \"IsDefault\" = true"); + + b.HasIndex("LearnerNoteId", "IsDeleted", "SortOrder"); + + b.HasIndex("UserId", "IsDeleted", "IsFavorite"); + + b.ToTable("NotebookPages", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DeliveredTokens") + .HasColumnType("text"); + + b.Property("IdempotencyKey") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsRead") + .HasColumnType("boolean"); + + b.Property("LinkUrl") + .HasColumnType("text"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IdempotencyKey") + .IsUnique() + .HasFilter("\"IdempotencyKey\" IS NOT NULL"); + + b.HasIndex("UserId", "IsRead"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.OrganizationPayoutAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountHolderName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("BankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BankName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ChannelCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ConfiguredByAdminId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsVerified") + .HasColumnType("boolean"); + + b.Property("MaskedAccountNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ProviderAccountReference") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ProviderType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("VerifiedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ChannelCode") + .IsUnique(); + + b.HasIndex("ConfiguredByAdminId"); + + b.ToTable("OrganizationPayoutAccounts"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExercise", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LanguageSkillId") + .HasColumnType("integer"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PassingScorePercent") + .ValueGeneratedOnAdd() + .HasColumnType("double precision") + .HasDefaultValue(70.0); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasDefaultValue("LessonQuickCheck"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("TopicId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("LanguageSkillId"); + + b.HasIndex("TopicId"); + + b.HasIndex("LessonId", "LanguageSkillId"); + + b.HasIndex("Scope", "CertificateLevelId"); + + b.HasIndex("Scope", "TopicId"); + + b.ToTable("PracticeExercises"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExerciseAttempt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HomeworkAssignmentId") + .HasColumnType("integer"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PracticeExerciseId") + .HasColumnType("integer"); + + b.Property("ScorePercent") + .HasColumnType("double precision"); + + b.Property("StartedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PracticeExerciseId"); + + b.HasIndex("HomeworkAssignmentId", "PracticeExerciseId") + .IsUnique(); + + b.HasIndex("UserId", "PracticeExerciseId", "StartedAt"); + + b.ToTable("PracticeExerciseAttempts"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Explanation") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PracticeExerciseId") + .HasColumnType("integer"); + + b.Property("QuestionText") + .IsRequired() + .HasColumnType("text"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PracticeExerciseId"); + + b.ToTable("PracticeQuestions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeQuestionOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsCorrect") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OptionText") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("PracticeQuestionId") + .HasColumnType("integer"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PracticeQuestionId"); + + b.ToTable("PracticeQuestionOptions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeSubmission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("CertificateLevelId") + .HasColumnType("integer") + .HasColumnName("CertificationLevelId"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("TextContent") + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("UserId", "Type", "SubmittedAt"); + + b.ToTable("PracticeSubmissions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.RecommendedLearningPath", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BaseActivePathId") + .HasColumnType("integer"); + + b.Property("ConfirmedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("GeneratedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsViewed") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PreviewExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("StartingCertificateLevelId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("SuggestionJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("Summary") + .HasColumnType("text"); + + b.Property("TargetCertificateLevelId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique() + .HasFilter("\"Status\" = 'Active'"); + + b.HasIndex("UserId", "GeneratedAt"); + + b.HasIndex("UserId", "Version") + .IsUnique(); + + b.ToTable("RecommendedLearningPaths"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ReviewCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcceptedReadingsJson") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("ArchivedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("AudioUrl") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("BackText") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)") + .HasDefaultValue(""); + + b.Property("CardType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasDefaultValue("Vocabulary"); + + b.Property("ContextSnippet") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CorrectCount") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EaseFactor") + .HasColumnType("double precision"); + + b.Property("ExampleMeaning") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ExampleSentence") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FrontText") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasDefaultValue(""); + + b.Property("GrammarPatternId") + .HasColumnType("integer") + .HasColumnName("GrammarPointId"); + + b.Property("IncorrectCount") + .HasColumnType("integer"); + + b.Property("IntervalDays") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("JlptLevel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("KanjiId") + .HasColumnType("integer") + .HasColumnName("KanjiEntryId"); + + b.Property("Lapses") + .HasColumnType("integer"); + + b.Property("LastReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("LearnerNoteEntryId") + .HasColumnType("integer") + .HasColumnName("VocabularyNoteEntryId"); + + b.Property("LearningState") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("New"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("MasteredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Meaning") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Mode") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NextReviewDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NormalizedContentKey") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(300) + .HasColumnType("character varying(300)") + .HasDefaultValue(""); + + b.Property("PersonalNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Reading") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Repetitions") + .HasColumnType("integer"); + + b.Property("Revision") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SourceId") + .HasColumnType("integer"); + + b.Property("SourceLabel") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("SourceLinksJson") + .HasMaxLength(4000) + .HasColumnType("character varying(4000)"); + + b.Property("SourceType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(40) + .HasColumnType("character varying(40)") + .HasDefaultValue("Manual"); + + b.Property("SourceVersion") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SrsCardTemplateId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Active"); + + b.Property("SuspendedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SynonymsJson") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("VocabularyId") + .HasColumnType("integer"); + + b.Property("WritingCorrectStrokeCount") + .HasColumnType("integer"); + + b.Property("WritingPracticeMode") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("WritingScore") + .HasColumnType("integer"); + + b.Property("WritingScoreUpdatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("WritingTotalStrokeCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GrammarPatternId"); + + b.HasIndex("KanjiId"); + + b.HasIndex("LearnerNoteEntryId"); + + b.HasIndex("LessonId"); + + b.HasIndex("SrsCardTemplateId"); + + b.HasIndex("VocabularyId"); + + b.HasIndex("UserId", "NextReviewDate"); + + b.HasIndex("UserId", "GrammarPatternId", "Mode") + .IsUnique() + .HasFilter("\"GrammarPointId\" IS NOT NULL"); + + b.HasIndex("UserId", "KanjiId", "Mode") + .IsUnique() + .HasFilter("\"KanjiEntryId\" IS NOT NULL"); + + b.HasIndex("UserId", "NormalizedContentKey", "Mode") + .IsUnique() + .HasFilter("\"NormalizedContentKey\" <> '' AND \"IsDeleted\" = false"); + + b.HasIndex("UserId", "VocabularyId", "Mode") + .IsUnique() + .HasFilter("\"VocabularyId\" IS NOT NULL"); + + b.HasIndex("UserId", "Status", "LearningState", "NextReviewDate"); + + b.ToTable("ReviewCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ReviewHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IdempotencyKey") + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.Property("IsCorrect") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NewEaseFactor") + .ValueGeneratedOnAdd() + .HasColumnType("double precision") + .HasDefaultValue(2.5); + + b.Property("NewIntervalDays") + .HasColumnType("integer"); + + b.Property("NewState") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Learning"); + + b.Property("PreviousEaseFactor") + .ValueGeneratedOnAdd() + .HasColumnType("double precision") + .HasDefaultValue(2.5); + + b.Property("PreviousIntervalDays") + .HasColumnType("integer"); + + b.Property("PreviousState") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("New"); + + b.Property("Quality") + .HasColumnType("integer"); + + b.Property("Rating") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("ResponseTimeMs") + .HasColumnType("integer"); + + b.Property("ReviewCardId") + .HasColumnType("integer") + .HasColumnName("ReviewItemId"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("SessionReference") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("StudyMode") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("flip"); + + b.Property("UserAnswer") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.HasKey("Id"); + + b.HasIndex("SessionReference"); + + b.HasIndex("ReviewCardId", "IdempotencyKey") + .IsUnique() + .HasFilter("\"IdempotencyKey\" IS NOT NULL"); + + b.HasIndex("ReviewCardId", "ReviewedAt"); + + b.ToTable("ReviewHistories"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SrsCardTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcceptedReadingsJson") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("AudioUrl") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("BackText") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CardType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExampleMeaning") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ExampleSentence") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FrontText") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("GrammarPatternId") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("JlptLevel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("KanjiId") + .HasColumnType("integer"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.Property("Meaning") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NormalizedContentKey") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("Reading") + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("ReviewNote") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ReviewedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("ReviewedByAdminId") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(24) + .HasColumnType("character varying(24)"); + + b.Property("SubmittedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("SubmittedByUserId") + .HasColumnType("integer"); + + b.Property("SynonymsJson") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("UnpublishedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UnpublishedReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UsageNotes") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("VocabularyId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("GrammarPatternId"); + + b.HasIndex("KanjiId"); + + b.HasIndex("LessonId"); + + b.HasIndex("NormalizedContentKey"); + + b.HasIndex("ReviewedByAdminId"); + + b.HasIndex("VocabularyId"); + + b.HasIndex("SubmittedByUserId", "Status"); + + b.HasIndex("Status", "JlptLevel", "CardType"); + + b.ToTable("SrsCardTemplates"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SrsReviewSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CompletedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("CompletedCardIdsJson") + .IsRequired() + .HasMaxLength(8000) + .HasColumnType("character varying(8000)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DeadlineAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("FilterCardType") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("FilterJlptLevel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("FilterLearningState") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("FilterSourceType") + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("ForgotCount") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LastActivityAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ProcessedStepKeysJson") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(8000) + .HasColumnType("character varying(8000)") + .HasDefaultValue("[]"); + + b.Property("QueueCardIdsJson") + .IsRequired() + .HasMaxLength(8000) + .HasColumnType("character varying(8000)"); + + b.Property("RememberedCount") + .HasColumnType("integer"); + + b.Property("RequestedCount") + .HasColumnType("integer"); + + b.Property("RetryCardIdsJson") + .IsRequired() + .HasMaxLength(8000) + .HasColumnType("character varying(8000)"); + + b.Property("ReviewedCount") + .HasColumnType("integer"); + + b.Property("SelectionScope") + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("SessionKey") + .HasColumnType("uuid"); + + b.Property("SessionKind") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Scheduled"); + + b.Property("ShuffleEnabled") + .HasColumnType("boolean"); + + b.Property("StartedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("StudyMode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("TimeLimitMinutes") + .HasColumnType("integer"); + + b.Property("TotalInitialCards") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SessionKey") + .IsUnique(); + + b.HasIndex("UserId", "Status", "LastActivityAtUtc"); + + b.HasIndex("UserId", "SessionKind", "Status", "LastActivityAtUtc"); + + b.ToTable("SrsReviewSessions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohort", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CancellationReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CancelledAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property("CapacitySnapshot") + .HasColumnType("integer"); + + b.Property("CourseDurationWeeks") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("EndsAt") + .HasColumnType("timestamp without time zone"); + + b.Property("EnrollmentClosedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EnrollmentClosesAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EnrollmentOpensAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupPolicyId") + .HasColumnType("integer"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("character varying(12)"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SourceProposalId") + .HasColumnType("integer"); + + b.Property("StartsAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalTuitionSnapshot") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("TuitionPerSessionSnapshot") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("TuitionPolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("TuitionSnapshotAtUtc") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GroupPolicyId"); + + b.HasIndex("MentorId"); + + b.HasIndex("SourceProposalId") + .IsUnique() + .HasFilter("\"SourceProposalId\" IS NOT NULL"); + + b.ToTable("StudyCohorts", null, t => + { + t.HasCheckConstraint("CK_StudyCohort_Capacity", "\"Capacity\" > 0"); + + t.HasCheckConstraint("CK_StudyCohort_DurationWeeks", "\"CourseDurationWeeks\" >= 1"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortMentorAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AffectedSessionCount") + .HasColumnType("integer"); + + b.Property("AssignedById") + .HasColumnType("integer"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EffectiveFromSessionNumber") + .HasColumnType("integer"); + + b.Property("EffectiveFromUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("ImpactSnapshot") + .IsRequired() + .HasColumnType("text"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("PolicyId") + .HasColumnType("integer"); + + b.Property("PolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("PreviousMentorId") + .HasColumnType("integer"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.HasKey("Id"); + + b.HasIndex("AssignedById"); + + b.HasIndex("IdempotencyKey") + .IsUnique(); + + b.HasIndex("MentorId"); + + b.HasIndex("PolicyId"); + + b.HasIndex("PreviousMentorId"); + + b.HasIndex("CohortId", "Id"); + + b.ToTable("StudyCohortMentorAssignments", null, t => + { + t.HasCheckConstraint("CK_StudyCohortMentorAssignment_DifferentMentor", "\"MentorId\" <> \"PreviousMentorId\""); + + t.HasCheckConstraint("CK_StudyCohortMentorAssignment_Reason", "length(btrim(\"Reason\")) > 0"); + + t.HasCheckConstraint("CK_StudyCohortMentorAssignment_Sessions", "\"EffectiveFromSessionNumber\" > 0 AND \"AffectedSessionCount\" > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortMentorInvitation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedByAdminId") + .HasColumnType("integer"); + + b.Property("AssignmentReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ChangeReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CohortRevisionAtInvite") + .HasColumnType("integer"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("DeclineReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FromSessionNumber") + .HasColumnType("integer"); + + b.Property("IdempotencyKey") + .HasColumnType("uuid"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("RespondedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("Status") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(24) + .HasColumnType("character varying(24)"); + + b.HasKey("Id"); + + b.HasIndex("AssignedByAdminId"); + + b.HasIndex("CohortId") + .IsUnique() + .HasFilter("\"Status\" = 'Pending'"); + + b.HasIndex("IdempotencyKey") + .IsUnique(); + + b.HasIndex("MentorId", "Status"); + + b.ToTable("StudyCohortMentorInvitations", null, t => + { + t.HasCheckConstraint("CK_CohortMentorInvitation_ChangeReason", "\"Status\" <> 'ChangeRequested' OR length(btrim(coalesce(\"ChangeReason\", ''))) > 0"); + + t.HasCheckConstraint("CK_CohortMentorInvitation_DeclineReason", "\"Status\" <> 'Declined' OR length(btrim(coalesce(\"DeclineReason\", ''))) > 0"); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActualEndedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ActualStartedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("AvailabilityId") + .HasColumnType("integer"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("Number") + .HasColumnType("integer"); + + b.Property("Status") + .IsConcurrencyToken() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.HasKey("Id"); + + b.HasIndex("AvailabilityId") + .IsUnique(); + + b.HasIndex("CohortId", "Number") + .IsUnique(); + + b.ToTable("StudyCohortSessions", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("CancellationReason") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("CancelledAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("CapacitySnapshot") + .HasColumnType("integer"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CheckoutUrl") + .HasColumnType("text"); + + b.Property("CohortId") + .HasColumnType("integer"); + + b.Property("CompletedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("DurationMonths") + .HasColumnType("integer"); + + b.Property("EndsAt") + .HasColumnType("timestamp without time zone"); + + b.Property("GroupPolicyId") + .HasColumnType("integer"); + + b.Property("LearnerId") + .HasColumnType("integer"); + + b.Property("MaximumAbsencePercent") + .HasColumnType("integer"); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MinimumHomeworkPercent") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("OrderSnapshot") + .HasColumnType("text"); + + b.Property("PaymentConfirmedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentReference") + .HasColumnType("text"); + + b.Property("PaymentReviewReason") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PaymentStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanId") + .HasColumnType("integer"); + + b.Property("PlanRevision") + .HasColumnType("integer"); + + b.Property("PolicyVersionSnapshot") + .HasColumnType("integer"); + + b.Property("ProviderPaymentReference") + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.Property("PurchaseKey") + .HasColumnType("uuid"); + + b.Property("RefundedAmount") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("RefundedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("RetakeClaimDays") + .HasColumnType("integer"); + + b.Property("RetakeOfId") + .HasColumnType("integer"); + + b.Property("SessionMinutes") + .HasColumnType("integer"); + + b.Property("SessionType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("Individual"); + + b.Property("SessionsPerWeek") + .HasColumnType("integer"); + + b.Property("StartsAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("TargetExamDate") + .HasColumnType("timestamp without time zone"); + + b.Property("TotalSessions") + .HasColumnType("integer"); + + b.Property("TransferredAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("TransferredFromCourseId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("CohortId"); + + b.HasIndex("GroupPolicyId"); + + b.HasIndex("MentorId"); + + b.HasIndex("PlanId"); + + b.HasIndex("ProviderPaymentReference") + .IsUnique() + .HasDatabaseName("IX_StudyCourses_ProviderPaymentReference") + .HasFilter("\"ProviderPaymentReference\" IS NOT NULL"); + + b.HasIndex("RetakeOfId") + .IsUnique(); + + b.HasIndex("TransferredFromCourseId") + .IsUnique() + .HasFilter("\"TransferredFromCourseId\" IS NOT NULL"); + + b.HasIndex("CohortId", "LearnerId") + .IsUnique() + .HasDatabaseName("IX_StudyCourses_Cohort_ActiveLearner") + .HasFilter("\"CohortId\" IS NOT NULL AND \"Status\" = 'Active'"); + + b.HasIndex("LearnerId", "PurchaseKey") + .IsUnique(); + + b.ToTable("StudyCourses", null, t => + { + t.HasCheckConstraint("CK_StudyCourses_RefundedAmount", "\"RefundedAmount\" >= 0 AND \"RefundedAmount\" <= \"Amount\""); + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourseHomework", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("DueAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Feedback") + .HasColumnType("text"); + + b.Property("Instructions") + .IsRequired() + .HasColumnType("text"); + + b.Property("Passed") + .HasColumnType("boolean"); + + b.Property("Required") + .HasColumnType("boolean"); + + b.Property("ReviewedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Submission") + .HasMaxLength(20000) + .HasColumnType("character varying(20000)"); + + b.Property("SubmittedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("StudyCourseHomework", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCoursePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Capacity") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("DurationMonths") + .HasColumnType("integer"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Price") + .HasPrecision(18) + .HasColumnType("numeric(18,0)"); + + b.Property("RetakeClaimDays") + .HasColumnType("integer"); + + b.Property("Revision") + .IsConcurrencyToken() + .HasColumnType("integer"); + + b.Property("SessionMinutes") + .HasColumnType("integer"); + + b.Property("SessionType") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("Individual"); + + b.Property("SessionsPerWeek") + .HasColumnType("integer"); + + b.Property("TargetExamDate") + .HasColumnType("timestamp without time zone"); + + b.Property("TotalSessions") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.ToTable("StudyCoursePlans", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourseSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Attempt") + .HasColumnType("integer"); + + b.Property("AvailabilityId") + .HasColumnType("integer"); + + b.Property("ConfirmedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ConfirmedById") + .HasColumnType("integer"); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("MeetingUrl") + .HasColumnType("text"); + + b.Property("Note") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Number") + .HasColumnType("integer"); + + b.Property("ScheduledAt") + .HasColumnType("timestamp without time zone"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.HasKey("Id"); + + b.HasIndex("AvailabilityId"); + + b.HasIndex("CourseId", "Number", "Attempt") + .IsUnique(); + + b.ToTable("StudyCourseSessions", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SubscriptionPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiGradingQuota") + .HasColumnType("integer"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DurationDays") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsPopular") + .HasColumnType("boolean"); + + b.Property("IsTrial") + .HasColumnType("boolean"); + + b.Property("MeetingSessionCount") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("PlanCategory") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(32) + .HasColumnType("character varying(32)") + .HasDefaultValue("self_study"); + + b.Property("Price") + .HasColumnType("decimal(18,0)"); + + b.Property("Revision") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.ToTable("SubscriptionPlans", t => + { + t.HasCheckConstraint("CK_SubscriptionPlans_AiGradingQuota", "\"AiGradingQuota\" >= 0"); + + t.HasCheckConstraint("CK_SubscriptionPlans_DurationDays", "\"DurationDays\" >= 0"); + + t.HasCheckConstraint("CK_SubscriptionPlans_Price", "\"Price\" >= 0"); + + t.HasCheckConstraint("CK_SubscriptionPlans_SortOrder", "\"SortOrder\" >= 0"); + }); + + b.HasData( + new + { + Id = 1, + AiGradingQuota = 1, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 1 tuần.", + DurationDays = 7, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 1 tuần", + PlanCategory = "self_study", + Price = 1000m, + Revision = 1, + SortOrder = 6 + }, + new + { + Id = 2, + AiGradingQuota = 2, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 2 tuần.", + DurationDays = 14, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 2 tuần", + PlanCategory = "self_study", + Price = 1000m, + Revision = 1, + SortOrder = 5 + }, + new + { + Id = 3, + AiGradingQuota = 3, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 3 tuần.", + DurationDays = 21, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 3 tuần", + PlanCategory = "self_study", + Price = 2000m, + Revision = 1, + SortOrder = 4 + }, + new + { + Id = 4, + AiGradingQuota = 5, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 1 tháng.", + DurationDays = 30, + IsActive = true, + IsDeleted = false, + IsPopular = true, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 1 tháng", + PlanCategory = "self_study", + Price = 2000m, + Revision = 1, + SortOrder = 3 + }, + new + { + Id = 5, + AiGradingQuota = 10, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 2 tháng.", + DurationDays = 60, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 2 tháng", + PlanCategory = "self_study", + Price = 3000m, + Revision = 1, + SortOrder = 2 + }, + new + { + Id = 6, + AiGradingQuota = 15, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Truy cập nội dung ôn luyện các chứng chỉ tiếng Nhật trong 3 tháng.", + DurationDays = 90, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Tự học tiếng Nhật - 3 tháng", + PlanCategory = "self_study", + Price = 3000m, + Revision = 1, + SortOrder = 1 + }, + new + { + Id = 7, + AiGradingQuota = 0, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Gói demo gồm 12 buổi ôn luyện 1-1 với Mentor, thời hạn 90 ngày. Dữ liệu thanh toán demo được seed để kiểm thử đặt lịch trên frontend.", + DurationDays = 90, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 12, + Name = "Meeting 1-1 với Mentor - 12 buổi", + PlanCategory = "mentor_legacy", + Price = 1000m, + Revision = 1, + SortOrder = 7 + }, + new + { + Id = 8101, + AiGradingQuota = 1, + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Một lượt luyện nói và chấm phát âm tiếng Nhật bằng AI.", + DurationDays = 0, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Luyện nói AI - 1 lượt", + PlanCategory = "speaking", + Price = 1000m, + Revision = 1, + SortOrder = 10 + }, + new + { + Id = 8102, + AiGradingQuota = 1, + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Một lượt chấm bài viết tiếng Nhật bằng AI.", + DurationDays = 0, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Luyện viết AI - 1 lượt", + PlanCategory = "writing", + Price = 1000m, + Revision = 1, + SortOrder = 11 + }, + new + { + Id = 8103, + AiGradingQuota = 1, + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Một lượt giải thích chi tiết đáp án đề thi thử bằng AI.", + DurationDays = 0, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Giải thích đáp án AI - 1 lượt", + PlanCategory = "ai_grading", + Price = 1000m, + Revision = 1, + SortOrder = 12 + }, + new + { + Id = 8104, + AiGradingQuota = 1, + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Một lượt tạo lộ trình học cá nhân hóa bằng AI.", + DurationDays = 0, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 0, + Name = "Lộ trình học AI - 1 lượt", + PlanCategory = "learning_path", + Price = 1000m, + Revision = 1, + SortOrder = 13 + }, + new + { + Id = 8105, + AiGradingQuota = 0, + CreatedDate = new DateTime(2026, 11, 23, 0, 0, 0, 0, DateTimeKind.Utc), + Description = "Một buổi ôn luyện với mentor.", + DurationDays = 30, + IsActive = true, + IsDeleted = false, + IsPopular = false, + IsTrial = false, + MeetingSessionCount = 1, + Name = "Mentor - 1 buổi", + PlanCategory = "mentor_legacy", + Price = 1000m, + Revision = 1, + SortOrder = 14 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Topic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LearningObjectives") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.Property("StageCode") + .HasMaxLength(60) + .HasColumnType("character varying(60)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId", "SortOrder"); + + b.ToTable("Topics"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessedCertificateLevelId") + .HasColumnType("integer"); + + b.Property("AvatarUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("CurrentStreak") + .HasColumnType("integer"); + + b.Property("DailyStudyMinutes") + .HasColumnType("integer"); + + b.Property("DailyStudyMinutesMax") + .HasColumnType("integer"); + + b.Property("DailyStudyMinutesMin") + .HasColumnType("integer"); + + b.Property("DeclaredJlptCertificateCode") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("EmailNotificationsEnabled") + .HasColumnType("boolean"); + + b.Property("FirebaseUid") + .HasColumnType("text"); + + b.Property("FirstName") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("GoogleSubject") + .IsConcurrencyToken() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("IsEmailVerified") + .HasColumnType("boolean"); + + b.Property("IsPhoneVerified") + .HasColumnType("boolean"); + + b.Property("LastName") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("LastStudyDate") + .HasColumnType("timestamp without time zone"); + + b.Property("LearningGoalVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("LearningMode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("LongestStreak") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("NotificationPreferencesJson") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("PendingEmail") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("PendingEmailRequestedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("PlacementDecision") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("Role") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("SelfDeclaredCertificateLevelId") + .HasColumnType("integer"); + + b.Property("StartingCertificateLevelId") + .HasColumnType("integer"); + + b.Property("StudyTimePreference") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("SystemNotificationsEnabled") + .HasColumnType("boolean"); + + b.Property("TargetCertificateLevelId") + .HasColumnType("integer") + .HasColumnName("TargetCertificationLevelId"); + + b.Property("TargetExamDate") + .HasColumnType("timestamp without time zone"); + + b.Property("TokenVersion") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.HasKey("Id"); + + b.HasIndex("AssessedCertificateLevelId"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("GoogleSubject") + .IsUnique(); + + b.HasIndex("SelfDeclaredCertificateLevelId"); + + b.HasIndex("StartingCertificateLevelId"); + + b.HasIndex("TargetCertificateLevelId"); + + b.ToTable("Users"); + + b.HasData( + new + { + Id = 900001, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "admin@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Admin", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "System", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 91, 215, 217, 54, 239, 206, 181, 216, 143, 33, 82, 211, 9, 70, 197, 173, 197, 0, 72, 71, 59, 150, 46, 114, 96, 137, 52, 174, 137, 29, 196, 61, 50, 254, 249, 101, 114, 92, 149, 32, 55, 127, 205, 126, 216, 147, 197, 192, 248, 173, 158, 92, 104, 42, 195, 107, 150, 15, 3, 74, 103, 104, 3, 229 }, + PasswordSalt = new byte[] { 61, 240, 150, 172, 239, 48, 224, 17, 192, 54, 50, 58, 91, 100, 55, 168, 18, 69, 137, 112, 110, 59, 180, 37, 201, 241, 143, 238, 139, 33, 128, 70, 87, 158, 235, 219, 229, 184, 94, 72, 41, 160, 160, 197, 158, 217, 128, 188, 156, 255, 147, 13, 151, 37, 133, 164, 9, 252, 175, 124, 21, 15, 152, 196 }, + PlacementDecision = "NotTaken", + Role = "Admin", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900002, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "mentor1@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Mentor", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "One", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 17, 253, 106, 25, 89, 176, 204, 31, 142, 252, 245, 31, 64, 101, 213, 135, 164, 116, 40, 46, 173, 175, 8, 0, 69, 101, 65, 4, 90, 25, 176, 223, 153, 237, 220, 94, 55, 133, 227, 181, 70, 97, 155, 122, 50, 139, 216, 136, 88, 52, 76, 98, 250, 64, 52, 71, 146, 221, 225, 137, 106, 6, 178, 239 }, + PasswordSalt = new byte[] { 233, 77, 244, 252, 171, 97, 38, 140, 50, 138, 10, 54, 122, 165, 186, 85, 129, 82, 49, 10, 98, 44, 165, 57, 50, 7, 238, 166, 142, 224, 94, 49, 134, 226, 247, 110, 154, 139, 99, 204, 95, 39, 171, 235, 212, 26, 217, 87, 139, 118, 253, 125, 241, 255, 57, 22, 140, 171, 11, 168, 174, 202, 32, 17 }, + PlacementDecision = "NotTaken", + Role = "Mentor", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900003, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "mentor2@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Mentor", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Two", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 93, 130, 109, 171, 238, 187, 245, 15, 202, 89, 247, 220, 95, 192, 246, 138, 5, 75, 250, 28, 208, 28, 51, 79, 127, 28, 214, 237, 93, 221, 108, 26, 152, 66, 73, 65, 11, 147, 154, 102, 113, 49, 51, 24, 51, 197, 248, 254, 22, 98, 87, 249, 250, 104, 131, 74, 16, 18, 179, 200, 3, 3, 79, 47 }, + PasswordSalt = new byte[] { 240, 155, 254, 183, 129, 162, 74, 247, 41, 9, 67, 242, 128, 8, 226, 85, 5, 104, 104, 72, 101, 75, 130, 95, 47, 101, 116, 89, 207, 23, 119, 178, 38, 180, 185, 145, 58, 115, 14, 30, 85, 216, 169, 133, 94, 115, 11, 117, 96, 87, 227, 240, 204, 48, 51, 144, 170, 248, 167, 56, 175, 194, 253, 135 }, + PlacementDecision = "NotTaken", + Role = "Mentor", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900004, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "author1@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Content", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Author One", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 168, 249, 82, 144, 178, 145, 94, 164, 34, 152, 2, 74, 204, 105, 84, 145, 96, 199, 153, 136, 110, 82, 114, 113, 22, 139, 117, 143, 50, 239, 197, 4, 51, 189, 137, 48, 175, 14, 104, 164, 218, 249, 148, 217, 33, 44, 202, 128, 237, 183, 110, 228, 185, 36, 209, 254, 183, 182, 55, 1, 78, 16, 234, 50 }, + PasswordSalt = new byte[] { 19, 216, 84, 143, 3, 184, 50, 39, 209, 137, 149, 82, 224, 206, 6, 240, 237, 242, 172, 27, 55, 92, 242, 101, 149, 76, 104, 38, 176, 43, 40, 8, 102, 202, 146, 224, 62, 43, 147, 132, 2, 158, 81, 170, 29, 103, 76, 248, 101, 105, 213, 205, 32, 51, 59, 39, 221, 11, 135, 250, 193, 8, 78, 219 }, + PlacementDecision = "NotTaken", + Role = "ContentAuthor", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900005, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "author2@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Content", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Author Two", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 189, 121, 9, 1, 230, 137, 43, 239, 79, 56, 195, 196, 66, 116, 42, 1, 137, 55, 54, 249, 55, 231, 79, 224, 182, 182, 199, 133, 100, 39, 138, 5, 223, 215, 48, 46, 60, 214, 49, 88, 42, 186, 232, 116, 237, 89, 55, 144, 4, 78, 215, 231, 237, 220, 96, 225, 202, 97, 61, 165, 246, 28, 126, 198 }, + PasswordSalt = new byte[] { 66, 178, 77, 56, 234, 206, 29, 78, 136, 190, 160, 142, 226, 249, 14, 17, 26, 101, 167, 36, 193, 55, 150, 94, 239, 81, 69, 54, 81, 171, 80, 22, 208, 38, 242, 2, 55, 171, 64, 38, 48, 224, 36, 216, 133, 132, 147, 100, 174, 32, 65, 134, 128, 35, 50, 138, 204, 59, 167, 96, 11, 128, 101, 102 }, + PlacementDecision = "NotTaken", + Role = "ContentAuthor", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900006, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "learner.meeting@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Meeting", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Test Learner", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 9, 206, 219, 58, 155, 234, 107, 145, 121, 174, 134, 51, 96, 253, 64, 216, 157, 114, 92, 36, 123, 206, 67, 217, 207, 166, 54, 71, 254, 251, 156, 200, 185, 110, 198, 135, 221, 146, 243, 40, 237, 229, 16, 133, 163, 161, 156, 79, 138, 103, 85, 25, 114, 81, 99, 182, 25, 73, 212, 198, 212, 192, 54, 129 }, + PasswordSalt = new byte[] { 231, 202, 97, 95, 11, 9, 242, 47, 62, 77, 67, 36, 170, 78, 120, 81, 56, 69, 47, 36, 209, 212, 107, 244, 15, 34, 189, 110, 57, 66, 205, 213, 224, 19, 245, 192, 104, 146, 130, 44, 54, 107, 2, 15, 109, 136, 118, 220, 228, 44, 110, 219, 31, 100, 161, 164, 63, 231, 196, 79, 120, 106, 181, 71 }, + PlacementDecision = "NotTaken", + Role = "Learner", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900007, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "learner2.meeting@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Linh", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Nguyen", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 217, 79, 50, 159, 85, 88, 67, 15, 23, 182, 103, 80, 220, 85, 86, 173, 204, 186, 57, 67, 183, 165, 253, 243, 150, 250, 150, 190, 122, 252, 55, 169, 85, 236, 69, 106, 19, 219, 244, 42, 239, 30, 189, 176, 52, 47, 30, 28, 125, 31, 162, 255, 61, 3, 238, 201, 168, 88, 161, 42, 216, 86, 172, 219 }, + PasswordSalt = new byte[] { 85, 97, 108, 158, 219, 70, 81, 106, 73, 23, 205, 163, 105, 159, 117, 19, 175, 147, 178, 99, 112, 116, 163, 243, 109, 178, 129, 229, 245, 175, 91, 174, 66, 198, 122, 88, 80, 68, 160, 64, 85, 118, 105, 41, 135, 89, 49, 160, 120, 13, 116, 148, 255, 27, 157, 207, 106, 203, 127, 74, 19, 61, 148, 120 }, + PlacementDecision = "NotTaken", + Role = "Learner", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900008, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "learner3.meeting@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Minh", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Tran", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 84, 97, 164, 196, 63, 151, 182, 39, 139, 242, 152, 22, 179, 33, 174, 113, 0, 236, 253, 114, 234, 242, 209, 76, 196, 162, 143, 195, 180, 3, 178, 193, 205, 230, 18, 114, 49, 151, 198, 217, 254, 21, 94, 176, 146, 214, 235, 122, 28, 241, 164, 161, 4, 161, 209, 38, 102, 179, 31, 107, 157, 25, 35, 63 }, + PasswordSalt = new byte[] { 26, 188, 78, 205, 57, 115, 100, 129, 148, 135, 165, 205, 148, 203, 245, 36, 244, 177, 9, 104, 120, 140, 21, 164, 36, 75, 122, 51, 115, 69, 174, 180, 120, 155, 62, 37, 97, 227, 212, 134, 200, 7, 66, 255, 219, 10, 140, 149, 67, 86, 164, 170, 142, 165, 181, 103, 47, 100, 238, 24, 178, 29, 171, 226 }, + PlacementDecision = "NotTaken", + Role = "Learner", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }, + new + { + Id = 900009, + CreatedDate = new DateTime(2026, 9, 28, 0, 0, 0, 0, DateTimeKind.Utc), + CurrentStreak = 0, + DailyStudyMinutes = 30, + Email = "learner4.meeting@rikipath.local", + EmailNotificationsEnabled = true, + FirstName = "Hoang", + IsDeleted = false, + IsEmailVerified = true, + IsPhoneVerified = false, + LastName = "Pham", + LearningGoalVersion = 0, + LearningMode = "Standard", + LongestStreak = 0, + PasswordHash = new byte[] { 42, 30, 236, 129, 234, 192, 63, 84, 148, 163, 154, 246, 107, 147, 189, 95, 33, 141, 196, 67, 181, 51, 157, 136, 93, 228, 237, 165, 164, 49, 4, 146, 87, 84, 9, 47, 28, 59, 33, 130, 37, 63, 43, 229, 8, 178, 123, 74, 61, 159, 235, 68, 217, 51, 225, 29, 201, 104, 44, 152, 53, 255, 199, 28 }, + PasswordSalt = new byte[] { 83, 214, 138, 3, 142, 91, 229, 97, 238, 61, 48, 237, 80, 82, 112, 249, 166, 81, 53, 95, 170, 120, 13, 87, 113, 159, 60, 37, 75, 229, 226, 107, 229, 89, 60, 57, 109, 196, 235, 81, 145, 154, 110, 120, 141, 13, 142, 77, 41, 132, 58, 80, 154, 57, 226, 168, 176, 251, 113, 167, 242, 139, 7, 177 }, + PlacementDecision = "NotTaken", + Role = "Learner", + SystemNotificationsEnabled = true, + TokenVersion = 1 + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserDeviceToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("FcmToken") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LastSeenAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FcmToken") + .HasDatabaseName("IX_UserDeviceTokens_FcmToken"); + + b.HasIndex("UserId", "DeviceIdentifier") + .HasDatabaseName("IX_UserDeviceTokens_UserId_DeviceIdentifier"); + + b.HasIndex("UserId", "IsActive") + .HasDatabaseName("IX_UserDeviceTokens_UserId_IsActive"); + + b.ToTable("UserDeviceTokens", (string)null); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserSrsPreference", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoEnrollAfterLesson") + .HasColumnType("boolean"); + + b.Property("AutoPlayAudio") + .HasColumnType("boolean"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DailyNewLimit") + .HasColumnType("integer"); + + b.Property("DailyReminderEnabled") + .HasColumnType("boolean"); + + b.Property("DailyReviewLimit") + .HasColumnType("integer"); + + b.Property("EmailReminderEnabled") + .HasColumnType("boolean"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("LastReminderSentAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("LastReminderSentLocalDate") + .HasColumnType("date"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PreferredLocale") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("PreferredReviewMode") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("ReminderDaysJson") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ReminderFrequency") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("character varying(30)"); + + b.Property("ReminderHour") + .HasColumnType("integer"); + + b.Property("ReminderMinute") + .HasColumnType("integer"); + + b.Property("ShowFuriganaHint") + .HasColumnType("boolean"); + + b.Property("TimezoneId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.HasIndex("DailyReminderEnabled", "LastReminderSentLocalDate"); + + b.ToTable("UserSrsPreferences"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AiGradingQuota") + .HasColumnType("integer"); + + b.Property("AiGradingUsedCount") + .HasColumnType("integer"); + + b.Property("AmountPaid") + .HasColumnType("decimal(18,2)"); + + b.Property("CertificateLevelId") + .HasColumnType("integer"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("DurationDaysSnapshot") + .HasColumnType("integer"); + + b.Property("EndDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("MeetingSessionsIncluded") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("MeetingSessionsUsed") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0); + + b.Property("MentorId") + .HasColumnType("integer"); + + b.Property("MentorPracticeOutcomeJson") + .HasColumnType("text"); + + b.Property("MentorReviewCompletedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("MentorReviewPlan") + .HasMaxLength(6000) + .HasColumnType("character varying(6000)"); + + b.Property("MentorReviewSessionAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentExpiresAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("PaymentTransactionId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PendingMentorAvailabilityId") + .HasColumnType("integer"); + + b.Property("PendingMentorQuestion") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("PlanCategorySnapshot") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("PlanNameSnapshot") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("PlanRevisionSnapshot") + .HasColumnType("integer"); + + b.Property("PurchasedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("SubscriptionPlanId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("CertificateLevelId"); + + b.HasIndex("MentorId"); + + b.HasIndex("PendingMentorAvailabilityId"); + + b.HasIndex("SubscriptionPlanId"); + + b.HasIndex("UserId", "PaymentStatus", "EndDate"); + + b.ToTable("UserSubscriptions"); + + b.HasData( + new + { + Id = 990001, + AiGradingQuota = 0, + AiGradingUsedCount = 0, + AmountPaid = 459000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DurationDaysSnapshot = 90, + EndDate = new DateTime(2099, 12, 31, 23, 59, 59, 0, DateTimeKind.Unspecified), + IsDeleted = false, + MeetingSessionsIncluded = 12, + MeetingSessionsUsed = 0, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-MENTOR-12-SESSIONS", + PlanCategorySnapshot = "mentor_legacy", + PlanNameSnapshot = "Meeting 1-1 với Mentor - 12 buổi", + PlanRevisionSnapshot = 1, + PurchasedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + StartDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 7, + UserId = 900006, + Version = 0u + }, + new + { + Id = 990002, + AiGradingQuota = 0, + AiGradingUsedCount = 0, + AmountPaid = 459000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndDate = new DateTime(2026, 12, 30, 23, 59, 59, 0, DateTimeKind.Unspecified), + IsDeleted = false, + MeetingSessionsIncluded = 12, + MeetingSessionsUsed = 1, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-MENTOR-12-SESSIONS-2", + PurchasedAt = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + StartDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 7, + UserId = 900007, + Version = 0u + }, + new + { + Id = 990003, + AiGradingQuota = 0, + AiGradingUsedCount = 0, + AmountPaid = 459000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndDate = new DateTime(2026, 12, 30, 23, 59, 59, 0, DateTimeKind.Unspecified), + IsDeleted = false, + MeetingSessionsIncluded = 12, + MeetingSessionsUsed = 1, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-MENTOR-12-SESSIONS-3", + PurchasedAt = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + StartDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 7, + UserId = 900008, + Version = 0u + }, + new + { + Id = 990004, + AiGradingQuota = 0, + AiGradingUsedCount = 0, + AmountPaid = 459000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EndDate = new DateTime(2026, 12, 30, 23, 59, 59, 0, DateTimeKind.Unspecified), + IsDeleted = false, + MeetingSessionsIncluded = 12, + MeetingSessionsUsed = 1, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-MENTOR-12-SESSIONS-4", + PurchasedAt = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + StartDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 7, + UserId = 900009, + Version = 0u + }, + new + { + Id = 990005, + AiGradingQuota = 15, + AiGradingUsedCount = 0, + AmountPaid = 3000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DurationDaysSnapshot = 90, + EndDate = new DateTime(2099, 12, 31, 23, 59, 59, 0, DateTimeKind.Unspecified), + IsDeleted = false, + MeetingSessionsIncluded = 0, + MeetingSessionsUsed = 0, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-FULL-ACCESS-SELF-STUDY", + PlanCategorySnapshot = "self_study", + PlanNameSnapshot = "Tự học tiếng Nhật - 3 tháng", + PlanRevisionSnapshot = 1, + PurchasedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + StartDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 6, + UserId = 900006, + Version = 0u + }, + new + { + Id = 990006, + AiGradingQuota = 1, + AiGradingUsedCount = 0, + AmountPaid = 1000m, + CreatedDate = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + DurationDaysSnapshot = 0, + IsDeleted = false, + MeetingSessionsIncluded = 0, + MeetingSessionsUsed = 0, + PaymentStatus = "Paid", + PaymentTransactionId = "DEMO-FULL-ACCESS-LEARNING-PATH", + PlanCategorySnapshot = "learning_path", + PlanNameSnapshot = "Mua 1 lượt AI đề xuất lộ trình", + PlanRevisionSnapshot = 1, + PurchasedAt = new DateTime(2026, 10, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + SubscriptionPlanId = 8104, + UserId = 900006, + Version = 0u + }); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Vocabulary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AudioUrl") + .HasColumnType("text"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ExampleSentence") + .HasColumnType("text"); + + b.Property("ExampleSentenceMeaning") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("Meaning") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("character varying(300)"); + + b.Property("ModifiedBy") + .HasColumnType("uuid"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Reading") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasDefaultValue("Published"); + + b.Property("UnpublishedAtUtc") + .HasColumnType("timestamp without time zone"); + + b.Property("UnpublishedReason") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UserAccountId") + .HasColumnType("integer"); + + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1); + + b.Property("Word") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("UserAccountId"); + + b.HasIndex("Word", "Reading"); + + b.ToTable("Vocabularies"); + }); + + modelBuilder.Entity("FeatureSubscriptionPlan", b => + { + b.HasOne("RikiPath.Domain.Entities.Feature", null) + .WithMany() + .HasForeignKey("FeaturesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.SubscriptionPlan", null) + .WithMany() + .HasForeignKey("SubscriptionPlansId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.AiCreditTopUp", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("AiCreditTopUps") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateLevel", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateType", "CertificateType") + .WithMany("Levels") + .HasForeignKey("CertificateTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateType"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateSection", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ClassQuiz", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("Cohort"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ClassQuizAssignment", b => + { + b.HasOne("RikiPath.Domain.Entities.MockTestAttempt", "Attempt") + .WithMany() + .HasForeignKey("AttemptId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Enrollment") + .WithMany() + .HasForeignKey("EnrollmentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.ClassQuiz", "Quiz") + .WithMany("Assignments") + .HasForeignKey("QuizId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Attempt"); + + b.Navigation("Enrollment"); + + b.Navigation("Learner"); + + b.Navigation("Quiz"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortComplaint", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCourseSession", "CourseSession") + .WithMany() + .HasForeignKey("CourseSessionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("DecidedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cohort"); + + b.Navigation("Course"); + + b.Navigation("CourseSession"); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortComplaintEvent", b => + { + b.HasOne("RikiPath.Domain.Entities.CohortComplaint", "Complaint") + .WithMany("History") + .HasForeignKey("ComplaintId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complaint"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortEnrollmentEntitlement", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCoursePlan", "Plan") + .WithMany() + .HasForeignKey("PlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "StudyCohort") + .WithMany() + .HasForeignKey("StudyCohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Learner"); + + b.Navigation("Plan"); + + b.Navigation("StudyCohort"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortLearningFeedback", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCourseSession", "CourseSession") + .WithMany() + .HasForeignKey("CourseSessionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("RespondedById") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Course"); + + b.Navigation("CourseSession"); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortMentorReview", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cohort"); + + b.Navigation("Course"); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortScheduleRequest", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("ReviewedById") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cohort"); + + b.Navigation("RequestedBy"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortScheduleRequestEvent", b => + { + b.HasOne("RikiPath.Domain.Entities.CohortScheduleRequest", "Request") + .WithMany("History") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortTransferRequest", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "DestinationCourse") + .WithMany() + .HasForeignKey("DestinationCourseId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", null) + .WithMany() + .HasForeignKey("PolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "RequestedTargetCohort") + .WithMany() + .HasForeignKey("RequestedTargetCohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("ReviewedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "SourceCohort") + .WithMany() + .HasForeignKey("SourceCohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "SourceCourse") + .WithMany() + .HasForeignKey("SourceCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "TargetCohort") + .WithMany() + .HasForeignKey("TargetCohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DestinationCourse"); + + b.Navigation("Learner"); + + b.Navigation("RequestedTargetCohort"); + + b.Navigation("SourceCohort"); + + b.Navigation("SourceCourse"); + + b.Navigation("TargetCohort"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortTransferRequestEvent", b => + { + b.HasOne("RikiPath.Domain.Entities.CohortTransferRequest", "Request") + .WithMany("History") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentApprovalRequest", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "SubmittedBy") + .WithMany() + .HasForeignKey("SubmittedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("SubmittedBy"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentAudioTranscription", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentBankItem", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Owner") + .WithMany() + .HasForeignKey("OwnerUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentLevelMapping", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany("ContentLevelMappings") + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.GrammarPattern", "GrammarPattern") + .WithMany("ContentLevelMappings") + .HasForeignKey("GrammarPatternId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.Kanji", "Kanji") + .WithMany("ContentLevelMappings") + .HasForeignKey("KanjiId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.Vocabulary", "Vocabulary") + .WithMany("ContentLevelMappings") + .HasForeignKey("VocabularyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CertificateLevel"); + + b.Navigation("GrammarPattern"); + + b.Navigation("Kanji"); + + b.Navigation("Vocabulary"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentPassage", b => + { + b.HasOne("RikiPath.Domain.Entities.MockTestSection", "MockTestSection") + .WithMany("Passages") + .HasForeignKey("MockTestSectionId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("MockTestSection"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseAuditEntry", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany("Audit") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseRetakeRequest", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany("RetakeRequests") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CourseScheduleRequest", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.EmailVerification", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "User") + .WithMany("EmailVerifications") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.GradingResult", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkSubmission", "HomeworkSubmission") + .WithOne("GradingResult") + .HasForeignKey("RikiPath.Domain.Entities.GradingResult", "HomeworkSubmissionId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.PracticeSubmission", "PracticeSubmission") + .WithOne("GradingResult") + .HasForeignKey("RikiPath.Domain.Entities.GradingResult", "PracticeSubmissionId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("HomeworkSubmission"); + + b.Navigation("PracticeSubmission"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.GrammarPattern", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("AuthoredGrammarPatterns") + .HasForeignKey("UserAccountId"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignment", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "StudyCourse") + .WithMany() + .HasForeignKey("StudyCourseId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cohort"); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + + b.Navigation("MentorBooking"); + + b.Navigation("StudyCourse"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentAttachment", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkAssignment", "HomeworkAssignment") + .WithMany("Attachments") + .HasForeignKey("HomeworkAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HomeworkAssignment"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentExercise", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkAssignment", "HomeworkAssignment") + .WithMany("Exercises") + .HasForeignKey("HomeworkAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.PracticeExercise", "PracticeExercise") + .WithMany() + .HasForeignKey("PracticeExerciseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("HomeworkAssignment"); + + b.Navigation("PracticeExercise"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignmentLesson", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkAssignment", "HomeworkAssignment") + .WithMany("HomeworkAssignmentLessons") + .HasForeignKey("HomeworkAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany("HomeworkAssignmentLessons") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HomeworkAssignment"); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkSubmission", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkAssignment", "HomeworkAssignment") + .WithOne("Submission") + .HasForeignKey("RikiPath.Domain.Entities.HomeworkSubmission", "HomeworkAssignmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("HomeworkAssignment"); + + b.Navigation("Learner"); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkSubmissionFile", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkSubmission", "HomeworkSubmission") + .WithMany("Files") + .HasForeignKey("HomeworkSubmissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HomeworkSubmission"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.JlptLevelPayCoefficient", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ConfiguredByAdmin") + .WithMany() + .HasForeignKey("ConfiguredByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("ConfiguredByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaWritingPracticeCard", b => + { + b.HasOne("RikiPath.Domain.Entities.KanaCharacter", "KanaCharacter") + .WithMany("PracticeCards") + .HasForeignKey("KanaCharacterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("KanaCharacter"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaWritingPracticeHistory", b => + { + b.HasOne("RikiPath.Domain.Entities.KanaWritingPracticeCard", "Card") + .WithMany("Histories") + .HasForeignKey("KanaWritingPracticeCardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Kanji", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("AuthoredKanjis") + .HasForeignKey("UserAccountId"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerEssay", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("LearnerEssays") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerFeedback", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Learner"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerHighlight", b => + { + b.HasOne("RikiPath.Domain.Entities.LearnerNoteEntry", "LinkedNoteEntry") + .WithMany() + .HasForeignKey("LinkedNoteEntryId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.ReviewCard", "LinkedReviewCard") + .WithMany() + .HasForeignKey("LinkedReviewCardId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LinkedNoteEntry"); + + b.Navigation("LinkedReviewCard"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNote", b => + { + b.HasOne("RikiPath.Domain.Entities.NotebookFolder", "Folder") + .WithMany("Files") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("LearnerNotes") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Folder"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNoteEntry", b => + { + b.HasOne("RikiPath.Domain.Entities.GrammarPattern", "GrammarPattern") + .WithMany() + .HasForeignKey("GrammarPatternId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.Kanji", "Kanji") + .WithMany("LearnerNoteEntries") + .HasForeignKey("KanjiId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.LearnerNote", "LearnerNote") + .WithMany("LearnerNoteEntries") + .HasForeignKey("LearnerNoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.NotebookPage", "NotebookPage") + .WithMany("SavedItems") + .HasForeignKey("NotebookPageId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.Vocabulary", "Vocabulary") + .WithMany("LearnerNoteEntries") + .HasForeignKey("VocabularyId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GrammarPattern"); + + b.Navigation("Kanji"); + + b.Navigation("LearnerNote"); + + b.Navigation("NotebookPage"); + + b.Navigation("Vocabulary"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerPracticeAnswer", b => + { + b.HasOne("RikiPath.Domain.Entities.PracticeExerciseAttempt", "PracticeExerciseAttempt") + .WithMany("Answers") + .HasForeignKey("PracticeExerciseAttemptId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.PracticeQuestion", "PracticeQuestion") + .WithMany("Answers") + .HasForeignKey("PracticeQuestionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.PracticeQuestionOption", "SelectedOption") + .WithMany() + .HasForeignKey("SelectedOptionId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("PracticeExerciseAttempt"); + + b.Navigation("PracticeQuestion"); + + b.Navigation("SelectedOption"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Lesson", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany("Lessons") + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.LanguageSkill", "LanguageSkill") + .WithMany("Lessons") + .HasForeignKey("LanguageSkillId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "PrerequisiteLesson") + .WithMany() + .HasForeignKey("PrerequisiteLessonId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.Topic", "Topic") + .WithMany("Lessons") + .HasForeignKey("TopicId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("AuthoredLessons") + .HasForeignKey("UserAccountId"); + + b.Navigation("CertificateLevel"); + + b.Navigation("LanguageSkill"); + + b.Navigation("PrerequisiteLesson"); + + b.Navigation("Topic"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonGrammar", b => + { + b.HasOne("RikiPath.Domain.Entities.GrammarPattern", "GrammarPattern") + .WithMany("LessonGrammars") + .HasForeignKey("GrammarPatternId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany("LessonGrammars") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GrammarPattern"); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonKanji", b => + { + b.HasOne("RikiPath.Domain.Entities.Kanji", "Kanji") + .WithMany("LessonKanjis") + .HasForeignKey("KanjiId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany("LessonKanjis") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Kanji"); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonProgress", b => + { + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany("LessonProgresses") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("LessonProgresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LessonVocabulary", b => + { + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany("LessonVocabularies") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Vocabulary", "Vocabulary") + .WithMany("LessonVocabularies") + .HasForeignKey("VocabularyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + + b.Navigation("Vocabulary"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAbuseReport", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Reporter") + .WithMany() + .HasForeignKey("ReporterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "TargetUser") + .WithMany() + .HasForeignKey("TargetUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MentorBooking"); + + b.Navigation("Reporter"); + + b.Navigation("TargetUser"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAttendanceApproval", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ReviewedByAdmin") + .WithMany() + .HasForeignKey("ReviewedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("MentorBooking"); + + b.Navigation("ReviewedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAttendanceRecord", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourseSession", "CourseSession") + .WithMany() + .HasForeignKey("CourseSessionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CourseSession"); + + b.Navigation("MentorBooking"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAvailability", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", "GroupPolicy") + .WithMany() + .HasForeignKey("GroupPolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany("MentorAvailabilities") + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorScheduleRule", "ScheduleRule") + .WithMany() + .HasForeignKey("MentorScheduleRuleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorWeeklyAvailability", "WeeklyAvailability") + .WithMany("Slots") + .HasForeignKey("MentorWeeklyAvailabilityId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorTeachingProposal", "TeachingProposal") + .WithMany("GeneratedAvailabilities") + .HasForeignKey("TeachingProposalId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GroupPolicy"); + + b.Navigation("Mentor"); + + b.Navigation("ScheduleRule"); + + b.Navigation("TeachingProposal"); + + b.Navigation("WeeklyAvailability"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBankAccount", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "VerifiedByAdmin") + .WithMany() + .HasForeignKey("VerifiedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("MentorUser"); + + b.Navigation("VerifiedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBooking", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CompensationLevel") + .WithMany() + .HasForeignKey("CompensationLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorCreditGrant", "CreditGrant") + .WithMany() + .HasForeignKey("CreditGrantId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "MentorAvailability") + .WithMany("MentorBookings") + .HasForeignKey("MentorAvailabilityId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserSubscription", "UserSubscription") + .WithMany("MentorBookings") + .HasForeignKey("UserSubscriptionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CompensationLevel"); + + b.Navigation("CreditGrant"); + + b.Navigation("MentorAvailability"); + + b.Navigation("UserSubscription"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingDayGuard", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingIntent", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Learner"); + + b.Navigation("MentorBooking"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingReservation", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "MentorAvailability") + .WithMany() + .HasForeignKey("MentorAvailabilityId", "MentorId") + .HasPrincipalKey("Id", "MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Mentor"); + + b.Navigation("MentorAvailability"); + + b.Navigation("MentorBooking"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBookingTerms", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "MentorAvailability") + .WithMany() + .HasForeignKey("MentorAvailabilityId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithOne() + .HasForeignKey("RikiPath.Domain.Entities.MentorBookingTerms", "MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MentorAvailability"); + + b.Navigation("MentorBooking"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCalendarConnection", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorChatMessage", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Sender") + .WithMany() + .HasForeignKey("SenderUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MentorBooking"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCreditEntry", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorCreditGrant", "CreditGrant") + .WithMany("Entries") + .HasForeignKey("CreditGrantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreditGrant"); + + b.Navigation("Learner"); + + b.Navigation("MentorBooking"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCreditGrant", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserSubscription", "UserSubscription") + .WithMany() + .HasForeignKey("UserSubscriptionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("Learner"); + + b.Navigation("UserSubscription"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorDispute", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ResolvedByAdmin") + .WithMany() + .HasForeignKey("ResolvedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + + b.Navigation("MentorBooking"); + + b.Navigation("ResolvedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorDisputeHistory", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorDispute", "Dispute") + .WithMany("Histories") + .HasForeignKey("DisputeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Dispute"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorEarningEntry", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorAttendanceApproval", "AttendanceApproval") + .WithMany() + .HasForeignKey("AttendanceApprovalId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "CreatedByAdmin") + .WithMany() + .HasForeignKey("CreatedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorPayrollPeriod", "PayrollPeriod") + .WithMany() + .HasForeignKey("PayrollPeriodId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("AttendanceApproval"); + + b.Navigation("CertificateLevel"); + + b.Navigation("CreatedByAdmin"); + + b.Navigation("MentorBooking"); + + b.Navigation("MentorUser"); + + b.Navigation("PayrollPeriod"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorGroupPolicy", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "CreatedByAdmin") + .WithMany() + .HasForeignKey("CreatedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "DeletedByAdmin") + .WithMany() + .HasForeignKey("DeletedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "LastAppliedByAdmin") + .WithMany() + .HasForeignKey("LastAppliedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UpdatedByAdmin") + .WithMany() + .HasForeignKey("UpdatedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedByAdmin"); + + b.Navigation("DeletedByAdmin"); + + b.Navigation("LastAppliedByAdmin"); + + b.Navigation("UpdatedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorHourlyRate", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ConfiguredByAdmin") + .WithMany() + .HasForeignKey("ConfiguredByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ConfiguredByAdmin"); + + b.Navigation("MentorUser"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorKpiPolicy", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "CreatedByAdmin") + .WithMany() + .HasForeignKey("CreatedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CreatedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayoutAttempt", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ConfirmedByAdmin") + .WithMany() + .HasForeignKey("ConfirmedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "InitiatedByAdmin") + .WithMany() + .HasForeignKey("InitiatedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBankAccount", "LockedBankAccount") + .WithMany() + .HasForeignKey("LockedBankAccountId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorPayoutObligation", "PayoutObligation") + .WithMany("Attempts") + .HasForeignKey("PayoutObligationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ConfirmedByAdmin"); + + b.Navigation("InitiatedByAdmin"); + + b.Navigation("LockedBankAccount"); + + b.Navigation("PayoutObligation"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayoutObligation", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ApprovedByAdmin") + .WithMany() + .HasForeignKey("ApprovedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBankAccount", "LockedBankAccount") + .WithMany() + .HasForeignKey("LockedBankAccountId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.OrganizationPayoutAccount", "OrganizationPayoutAccount") + .WithMany() + .HasForeignKey("OrganizationPayoutAccountId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorPayrollPeriod", "PayrollPeriod") + .WithMany() + .HasForeignKey("PayrollPeriodId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApprovedByAdmin"); + + b.Navigation("LockedBankAccount"); + + b.Navigation("MentorUser"); + + b.Navigation("OrganizationPayoutAccount"); + + b.Navigation("PayrollPeriod"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollAdjustment", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ApprovedByAdmin") + .WithMany() + .HasForeignKey("ApprovedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorPayrollPeriod", "PayrollPeriod") + .WithMany("Adjustments") + .HasForeignKey("PayrollPeriodId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApprovedByAdmin"); + + b.Navigation("PayrollPeriod"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollLine", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorEarningEntry", "EarningEntry") + .WithMany() + .HasForeignKey("EarningEntryId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorPayrollPeriod", "PayrollPeriod") + .WithMany("Lines") + .HasForeignKey("PayrollPeriodId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("EarningEntry"); + + b.Navigation("MentorBooking"); + + b.Navigation("PayrollPeriod"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollPeriod", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ApprovedByAdmin") + .WithMany() + .HasForeignKey("ApprovedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "PreparedByAdmin") + .WithMany() + .HasForeignKey("PreparedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApprovedByAdmin"); + + b.Navigation("MentorUser"); + + b.Navigation("PreparedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorProfile", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithOne("MentorProfile") + .HasForeignKey("RikiPath.Domain.Entities.MentorProfile", "MentorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorReview", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithMany() + .HasForeignKey("MentorBookingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + + b.Navigation("MentorBooking"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorSchedule", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorScheduleRule", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorSchedule", "Schedule") + .WithMany("Rules") + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Schedule"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingProposal", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCoursePlan", "CoursePlan") + .WithMany() + .HasForeignKey("CoursePlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", "GroupPolicy") + .WithMany() + .HasForeignKey("GroupPolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ReviewedByAdmin") + .WithMany() + .HasForeignKey("ReviewedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CertificateLevel"); + + b.Navigation("CoursePlan"); + + b.Navigation("GroupPolicy"); + + b.Navigation("Mentor"); + + b.Navigation("ReviewedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingProposalEvent", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorTeachingProposal", "Proposal") + .WithMany("Events") + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proposal"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingQualification", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "MentorUser") + .WithMany() + .HasForeignKey("MentorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "VerifiedByAdmin") + .WithMany() + .HasForeignKey("VerifiedByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("MentorUser"); + + b.Navigation("VerifiedByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTimesheetAdjustment", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCohortSession", "CohortSession") + .WithMany() + .HasForeignKey("CohortSessionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CohortSession"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorWeeklyAvailability", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestion", b => + { + b.HasOne("RikiPath.Domain.Entities.MockTestSection", "MockTestSection") + .WithMany("Questions") + .HasForeignKey("MockTestSectionId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.ContentPassage", "Passage") + .WithMany("Questions") + .HasForeignKey("PassageId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("MockTestSection"); + + b.Navigation("Passage"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestionOption", b => + { + b.HasOne("RikiPath.Domain.Entities.MockQuestion", "MockQuestion") + .WithMany("Options") + .HasForeignKey("MockQuestionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MockQuestion"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTest", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany("MockTests") + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("AuthoredMockTests") + .HasForeignKey("UserAccountId"); + + b.Navigation("CertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestAnswer", b => + { + b.HasOne("RikiPath.Domain.Entities.MockQuestion", "MockQuestion") + .WithMany("Answers") + .HasForeignKey("MockQuestionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MockTestAttempt", "MockTestAttempt") + .WithMany("Answers") + .HasForeignKey("MockTestAttemptId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MockQuestionOption", "SelectedOption") + .WithMany() + .HasForeignKey("SelectedOptionId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("MockQuestion"); + + b.Navigation("MockTestAttempt"); + + b.Navigation("SelectedOption"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestAttempt", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("MockTestAttempts") + .HasForeignKey("UserAccountId"); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestSection", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateSection", "CertificateSection") + .WithMany("MockTestSections") + .HasForeignKey("CertificateSectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.LanguageSkill", "LanguageSkill") + .WithMany("MockTestSections") + .HasForeignKey("LanguageSkillId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MockTest", "MockTest") + .WithMany("Sections") + .HasForeignKey("MockTestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CertificateSection"); + + b.Navigation("LanguageSkill"); + + b.Navigation("MockTest"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestSectionResult", b => + { + b.HasOne("RikiPath.Domain.Entities.MockTestAttempt", "MockTestAttempt") + .WithMany("SectionResults") + .HasForeignKey("MockTestAttemptId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MockTestSection", "MockTestSection") + .WithMany("SectionResults") + .HasForeignKey("MockTestSectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MockTestAttempt"); + + b.Navigation("MockTestSection"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Note", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorBooking", "MentorBooking") + .WithOne("Note") + .HasForeignKey("RikiPath.Domain.Entities.Note", "MentorBookingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("Notes") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MentorBooking"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookFolder", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookPage", b => + { + b.HasOne("RikiPath.Domain.Entities.LearnerNote", "LearnerNote") + .WithMany("Pages") + .HasForeignKey("LearnerNoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("LearnerNote"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Notification", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("Notifications") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.OrganizationPayoutAccount", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ConfiguredByAdmin") + .WithMany() + .HasForeignKey("ConfiguredByAdminId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ConfiguredByAdmin"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExercise", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.LanguageSkill", "LanguageSkill") + .WithMany() + .HasForeignKey("LanguageSkillId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.Topic", "Topic") + .WithMany() + .HasForeignKey("TopicId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("CertificateLevel"); + + b.Navigation("LanguageSkill"); + + b.Navigation("Lesson"); + + b.Navigation("Topic"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExerciseAttempt", b => + { + b.HasOne("RikiPath.Domain.Entities.HomeworkAssignment", "HomeworkAssignment") + .WithMany() + .HasForeignKey("HomeworkAssignmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.PracticeExercise", "PracticeExercise") + .WithMany("Attempts") + .HasForeignKey("PracticeExerciseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HomeworkAssignment"); + + b.Navigation("PracticeExercise"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeQuestion", b => + { + b.HasOne("RikiPath.Domain.Entities.PracticeExercise", "PracticeExercise") + .WithMany("Questions") + .HasForeignKey("PracticeExerciseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PracticeExercise"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeQuestionOption", b => + { + b.HasOne("RikiPath.Domain.Entities.PracticeQuestion", "PracticeQuestion") + .WithMany("Options") + .HasForeignKey("PracticeQuestionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PracticeQuestion"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeSubmission", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany("PracticeSubmissions") + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("PracticeSubmissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.RecommendedLearningPath", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("RecommendedLearningPaths") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ReviewCard", b => + { + b.HasOne("RikiPath.Domain.Entities.GrammarPattern", "GrammarPattern") + .WithMany("ReviewCards") + .HasForeignKey("GrammarPatternId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.Kanji", "Kanji") + .WithMany("ReviewCards") + .HasForeignKey("KanjiId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.LearnerNoteEntry", "LearnerNoteEntry") + .WithMany("ReviewCards") + .HasForeignKey("LearnerNoteEntryId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.SrsCardTemplate", "SrsCardTemplate") + .WithMany() + .HasForeignKey("SrsCardTemplateId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("ReviewCards") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.Vocabulary", "Vocabulary") + .WithMany() + .HasForeignKey("VocabularyId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GrammarPattern"); + + b.Navigation("Kanji"); + + b.Navigation("LearnerNoteEntry"); + + b.Navigation("Lesson"); + + b.Navigation("SrsCardTemplate"); + + b.Navigation("UserAccount"); + + b.Navigation("Vocabulary"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ReviewHistory", b => + { + b.HasOne("RikiPath.Domain.Entities.ReviewCard", "ReviewCard") + .WithMany("ReviewHistories") + .HasForeignKey("ReviewCardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReviewCard"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SrsCardTemplate", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.GrammarPattern", "GrammarPattern") + .WithMany() + .HasForeignKey("GrammarPatternId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.Kanji", "Kanji") + .WithMany() + .HasForeignKey("KanjiId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "ReviewedByAdmin") + .WithMany() + .HasForeignKey("ReviewedByAdminId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "SubmittedByUser") + .WithMany() + .HasForeignKey("SubmittedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.Vocabulary", "Vocabulary") + .WithMany() + .HasForeignKey("VocabularyId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("CertificateLevel"); + + b.Navigation("GrammarPattern"); + + b.Navigation("Kanji"); + + b.Navigation("Lesson"); + + b.Navigation("ReviewedByAdmin"); + + b.Navigation("SubmittedByUser"); + + b.Navigation("Vocabulary"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SrsReviewSession", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohort", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", "GroupPolicy") + .WithMany() + .HasForeignKey("GroupPolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorTeachingProposal", "SourceProposal") + .WithMany() + .HasForeignKey("SourceProposalId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("GroupPolicy"); + + b.Navigation("Mentor"); + + b.Navigation("SourceProposal"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortMentorAssignment", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("AssignedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", null) + .WithMany() + .HasForeignKey("PolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany() + .HasForeignKey("PreviousMentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cohort"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortMentorInvitation", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "AssignedByAdmin") + .WithMany() + .HasForeignKey("AssignedByAdminId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany() + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AssignedByAdmin"); + + b.Navigation("Cohort"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohortSession", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "Availability") + .WithMany() + .HasForeignKey("AvailabilityId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany("Sessions") + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Availability"); + + b.Navigation("Cohort"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourse", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.StudyCohort", "Cohort") + .WithMany("Enrollments") + .HasForeignKey("CohortId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorGroupPolicy", "GroupPolicy") + .WithMany() + .HasForeignKey("GroupPolicyId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Learner") + .WithMany() + .HasForeignKey("LearnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCoursePlan", "Plan") + .WithMany() + .HasForeignKey("PlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "RetakeOf") + .WithMany() + .HasForeignKey("RetakeOfId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", null) + .WithMany() + .HasForeignKey("TransferredFromCourseId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CertificateLevel"); + + b.Navigation("Cohort"); + + b.Navigation("GroupPolicy"); + + b.Navigation("Learner"); + + b.Navigation("Mentor"); + + b.Navigation("Plan"); + + b.Navigation("RetakeOf"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourseHomework", b => + { + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany("Homework") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCoursePlan", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourseSession", b => + { + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "Availability") + .WithMany() + .HasForeignKey("AvailabilityId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.StudyCourse", "Course") + .WithMany("Sessions") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Availability"); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SubscriptionPlan", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Topic", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserAccount", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "AssessedCertificateLevel") + .WithMany() + .HasForeignKey("AssessedCertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "SelfDeclaredCertificateLevel") + .WithMany() + .HasForeignKey("SelfDeclaredCertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "StartingCertificateLevel") + .WithMany() + .HasForeignKey("StartingCertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "TargetCertificateLevel") + .WithMany("LearnersTargeting") + .HasForeignKey("TargetCertificateLevelId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("AssessedCertificateLevel"); + + b.Navigation("SelfDeclaredCertificateLevel"); + + b.Navigation("StartingCertificateLevel"); + + b.Navigation("TargetCertificateLevel"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserDeviceToken", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserSrsPreference", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserSubscription", b => + { + b.HasOne("RikiPath.Domain.Entities.CertificateLevel", "CertificateLevel") + .WithMany() + .HasForeignKey("CertificateLevelId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.MentorAvailability", "PendingMentorAvailability") + .WithMany() + .HasForeignKey("PendingMentorAvailabilityId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("RikiPath.Domain.Entities.SubscriptionPlan", "SubscriptionPlan") + .WithMany("UserSubscriptions") + .HasForeignKey("SubscriptionPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RikiPath.Domain.Entities.UserAccount", "UserAccount") + .WithMany("UserSubscriptions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CertificateLevel"); + + b.Navigation("Mentor"); + + b.Navigation("PendingMentorAvailability"); + + b.Navigation("SubscriptionPlan"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Vocabulary", b => + { + b.HasOne("RikiPath.Domain.Entities.UserAccount", null) + .WithMany("AuthoredVocabularies") + .HasForeignKey("UserAccountId"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateLevel", b => + { + b.Navigation("ContentLevelMappings"); + + b.Navigation("LearnersTargeting"); + + b.Navigation("Lessons"); + + b.Navigation("MockTests"); + + b.Navigation("PracticeSubmissions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateSection", b => + { + b.Navigation("MockTestSections"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CertificateType", b => + { + b.Navigation("Levels"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ClassQuiz", b => + { + b.Navigation("Assignments"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortComplaint", b => + { + b.Navigation("History"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortScheduleRequest", b => + { + b.Navigation("History"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.CohortTransferRequest", b => + { + b.Navigation("History"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ContentPassage", b => + { + b.Navigation("Questions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.GrammarPattern", b => + { + b.Navigation("ContentLevelMappings"); + + b.Navigation("LessonGrammars"); + + b.Navigation("ReviewCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkAssignment", b => + { + b.Navigation("Attachments"); + + b.Navigation("Exercises"); + + b.Navigation("HomeworkAssignmentLessons"); + + b.Navigation("Submission"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.HomeworkSubmission", b => + { + b.Navigation("Files"); + + b.Navigation("GradingResult"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaCharacter", b => + { + b.Navigation("PracticeCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.KanaWritingPracticeCard", b => + { + b.Navigation("Histories"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Kanji", b => + { + b.Navigation("ContentLevelMappings"); + + b.Navigation("LearnerNoteEntries"); + + b.Navigation("LessonKanjis"); + + b.Navigation("ReviewCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LanguageSkill", b => + { + b.Navigation("Lessons"); + + b.Navigation("MockTestSections"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNote", b => + { + b.Navigation("LearnerNoteEntries"); + + b.Navigation("Pages"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.LearnerNoteEntry", b => + { + b.Navigation("ReviewCards"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Lesson", b => + { + b.Navigation("HomeworkAssignmentLessons"); + + b.Navigation("LessonGrammars"); + + b.Navigation("LessonKanjis"); + + b.Navigation("LessonProgresses"); + + b.Navigation("LessonVocabularies"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorAvailability", b => + { + b.Navigation("MentorBookings"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorBooking", b => + { + b.Navigation("Note"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorCreditGrant", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorDispute", b => + { + b.Navigation("Histories"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayoutObligation", b => + { + b.Navigation("Attempts"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorPayrollPeriod", b => + { + b.Navigation("Adjustments"); + + b.Navigation("Lines"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorSchedule", b => + { + b.Navigation("Rules"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorTeachingProposal", b => + { + b.Navigation("Events"); + + b.Navigation("GeneratedAvailabilities"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MentorWeeklyAvailability", b => + { + b.Navigation("Slots"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestion", b => + { + b.Navigation("Answers"); + + b.Navigation("Options"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTest", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestAttempt", b => + { + b.Navigation("Answers"); + + b.Navigation("SectionResults"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.MockTestSection", b => + { + b.Navigation("Passages"); + + b.Navigation("Questions"); + + b.Navigation("SectionResults"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookFolder", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.NotebookPage", b => + { + b.Navigation("SavedItems"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExercise", b => + { + b.Navigation("Attempts"); + + b.Navigation("Questions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeExerciseAttempt", b => + { + b.Navigation("Answers"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeQuestion", b => + { + b.Navigation("Answers"); + + b.Navigation("Options"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.PracticeSubmission", b => + { + b.Navigation("GradingResult"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.ReviewCard", b => + { + b.Navigation("ReviewHistories"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCohort", b => + { + b.Navigation("Enrollments"); + + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.StudyCourse", b => + { + b.Navigation("Audit"); + + b.Navigation("Homework"); + + b.Navigation("RetakeRequests"); + + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.SubscriptionPlan", b => + { + b.Navigation("UserSubscriptions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Topic", b => + { + b.Navigation("Lessons"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserAccount", b => + { + b.Navigation("AiCreditTopUps"); + + b.Navigation("AuthoredGrammarPatterns"); + + b.Navigation("AuthoredKanjis"); + + b.Navigation("AuthoredLessons"); + + b.Navigation("AuthoredMockTests"); + + b.Navigation("AuthoredVocabularies"); + + b.Navigation("EmailVerifications"); + + b.Navigation("LearnerEssays"); + + b.Navigation("LearnerNotes"); + + b.Navigation("LessonProgresses"); + + b.Navigation("MentorAvailabilities"); + + b.Navigation("MentorProfile"); + + b.Navigation("MockTestAttempts"); + + b.Navigation("Notes"); + + b.Navigation("Notifications"); + + b.Navigation("PracticeSubmissions"); + + b.Navigation("RecommendedLearningPaths"); + + b.Navigation("ReviewCards"); + + b.Navigation("UserSubscriptions"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.UserSubscription", b => + { + b.Navigation("MentorBookings"); + }); + + modelBuilder.Entity("RikiPath.Domain.Entities.Vocabulary", b => + { + b.Navigation("ContentLevelMappings"); + + b.Navigation("LearnerNoteEntries"); + + b.Navigation("LessonVocabularies"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.cs b/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.cs new file mode 100644 index 0000000..40963af --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261203073836_RemoveLegacyMockPublishMetadata.cs @@ -0,0 +1,153 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + /// + public partial class RemoveLegacyMockPublishMetadata : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + // InitialCreate (20261130043054) omitted these legacy shadow columns on fresh databases while + // pre-squash databases may still retain them. Use IF EXISTS so Up() is safe on both schemas. + migrationBuilder.Sql(""" + ALTER TABLE "MockQuestions" DROP CONSTRAINT IF EXISTS "FK_MockQuestions_CertificateLevels_CertificateLevelId"; + ALTER TABLE "MockQuestions" DROP CONSTRAINT IF EXISTS "FK_MockQuestions_LanguageSkills_LanguageSkillId"; + ALTER TABLE "MockQuestions" DROP CONSTRAINT IF EXISTS "FK_MockQuestions_MockQuestions_SourceQuestionId"; + DROP INDEX IF EXISTS "IX_MockQuestions_CertificateLevelId_LanguageSkillId_PublishSta~"; + DROP INDEX IF EXISTS "IX_MockQuestions_LanguageSkillId"; + DROP INDEX IF EXISTS "IX_MockQuestions_SourceQuestionId"; + ALTER TABLE "MockTests" DROP COLUMN IF EXISTS "PublishStatus"; + ALTER TABLE "MockTests" DROP COLUMN IF EXISTS "PublishedAt"; + ALTER TABLE "MockTests" DROP COLUMN IF EXISTS "RightsStatus"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "CertificateLevelId"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "LanguageSkillId"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "PublishStatus"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "PublishedAt"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "RightsStatus"; + ALTER TABLE "MockQuestions" DROP COLUMN IF EXISTS "SourceQuestionId"; + ALTER TABLE "ContentPassages" DROP COLUMN IF EXISTS "PublishStatus"; + ALTER TABLE "ContentPassages" DROP COLUMN IF EXISTS "PublishedAt"; + """); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PublishStatus", + table: "MockTests", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "PublishedAt", + table: "MockTests", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "RightsStatus", + table: "MockTests", + type: "character varying(100)", + maxLength: 100, + nullable: true); + + migrationBuilder.AddColumn( + name: "CertificateLevelId", + table: "MockQuestions", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "LanguageSkillId", + table: "MockQuestions", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "PublishStatus", + table: "MockQuestions", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "PublishedAt", + table: "MockQuestions", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "RightsStatus", + table: "MockQuestions", + type: "character varying(100)", + maxLength: 100, + nullable: true); + + migrationBuilder.AddColumn( + name: "SourceQuestionId", + table: "MockQuestions", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "PublishStatus", + table: "ContentPassages", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "PublishedAt", + table: "ContentPassages", + type: "timestamp without time zone", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_MockQuestions_CertificateLevelId_LanguageSkillId_PublishSta~", + table: "MockQuestions", + columns: new[] { "CertificateLevelId", "LanguageSkillId", "PublishStatus", "IsArchivedVersion" }); + + migrationBuilder.CreateIndex( + name: "IX_MockQuestions_LanguageSkillId", + table: "MockQuestions", + column: "LanguageSkillId"); + + migrationBuilder.CreateIndex( + name: "IX_MockQuestions_SourceQuestionId", + table: "MockQuestions", + column: "SourceQuestionId"); + + migrationBuilder.AddForeignKey( + name: "FK_MockQuestions_CertificateLevels_CertificateLevelId", + table: "MockQuestions", + column: "CertificateLevelId", + principalTable: "CertificateLevels", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MockQuestions_LanguageSkills_LanguageSkillId", + table: "MockQuestions", + column: "LanguageSkillId", + principalTable: "LanguageSkills", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MockQuestions_MockQuestions_SourceQuestionId", + table: "MockQuestions", + column: "SourceQuestionId", + principalTable: "MockQuestions", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 84e06cb..53e5939 100644 --- a/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -2172,12 +2172,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PlaybackPolicyJson") .HasColumnType("jsonb"); - b.Property("PublishStatus") - .HasColumnType("integer"); - - b.Property("PublishedAt") - .HasColumnType("timestamp without time zone"); - b.Property("SortOrder") .HasColumnType("integer"); @@ -8157,9 +8151,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AudioUrl") .HasColumnType("text"); - b.Property("CertificateLevelId") - .HasColumnType("integer"); - b.Property("ContentFingerprint") .IsRequired() .HasMaxLength(64) @@ -8193,9 +8184,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsDeleted") .HasColumnType("boolean"); - b.Property("LanguageSkillId") - .HasColumnType("integer"); - b.Property("MockTestSectionId") .HasColumnType("integer") .HasColumnName("PracticeTestSectionId"); @@ -8218,12 +8206,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PlaybackPolicyJson") .HasColumnType("jsonb"); - b.Property("PublishStatus") - .HasColumnType("integer"); - - b.Property("PublishedAt") - .HasColumnType("timestamp without time zone"); - b.Property("QuestionGroupTitle") .HasMaxLength(200) .HasColumnType("character varying(200)"); @@ -8245,19 +8227,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("QuestionVersion") .HasColumnType("integer"); - b.Property("RightsStatus") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - b.Property("SkillMetadataJson") .HasColumnType("jsonb"); b.Property("SortOrder") .HasColumnType("integer"); - b.Property("SourceQuestionId") - .HasColumnType("integer"); - b.Property("SourceReference") .HasMaxLength(300) .HasColumnType("character varying(300)"); @@ -8284,18 +8259,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContentFingerprint"); - b.HasIndex("LanguageSkillId"); - b.HasIndex("PassageId"); b.HasIndex("QuestionIdentity"); - b.HasIndex("SourceQuestionId"); - b.HasIndex("MockTestSectionId", "IsArchivedVersion"); - b.HasIndex("CertificateLevelId", "LanguageSkillId", "PublishStatus", "IsArchivedVersion"); - b.ToTable("MockQuestions"); }); @@ -8404,16 +8373,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ParentExamId") .HasColumnType("integer"); - b.Property("PublishStatus") - .HasColumnType("integer"); - - b.Property("PublishedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RightsStatus") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - b.Property("SourceReference") .HasMaxLength(300) .HasColumnType("character varying(300)"); @@ -13650,18 +13609,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("RikiPath.Domain.Entities.MockQuestion", b => { - b.HasOne("RikiPath.Domain.Entities.CertificateLevel", null) - .WithMany() - .HasForeignKey("CertificateLevelId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("RikiPath.Domain.Entities.LanguageSkill", null) - .WithMany() - .HasForeignKey("LanguageSkillId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - b.HasOne("RikiPath.Domain.Entities.MockTestSection", "MockTestSection") .WithMany("Questions") .HasForeignKey("MockTestSectionId") @@ -13672,11 +13619,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("PassageId") .OnDelete(DeleteBehavior.SetNull); - b.HasOne("RikiPath.Domain.Entities.MockQuestion", null) - .WithMany() - .HasForeignKey("SourceQuestionId") - .OnDelete(DeleteBehavior.SetNull); - b.Navigation("MockTestSection"); b.Navigation("Passage"); diff --git a/RikiPath.WebApi/Controllers/HighlightsController.cs b/RikiPath.WebApi/Controllers/HighlightsController.cs index 7940a03..de33532 100644 --- a/RikiPath.WebApi/Controllers/HighlightsController.cs +++ b/RikiPath.WebApi/Controllers/HighlightsController.cs @@ -4,12 +4,14 @@ using Microsoft.AspNetCore.Mvc; using RikiPath.Application.DTOs.Highlights; using RikiPath.Application.IServices; +using RikiPath.Domain.Enums; namespace RikiPath.WebApi.Controllers; [ApiController] [Route("api/[controller]")] [Authorize(Roles = "Learner")] +[RequireFeature(FeatureCodes.PersonalNotebook)] public class HighlightsController(ILearnerHighlightService highlightService) : ControllerBase { [HttpGet] diff --git a/RikiPath.WebApi/Controllers/LearningPathController.cs b/RikiPath.WebApi/Controllers/LearningPathController.cs index 62333d8..b5e31ef 100644 --- a/RikiPath.WebApi/Controllers/LearningPathController.cs +++ b/RikiPath.WebApi/Controllers/LearningPathController.cs @@ -17,10 +17,18 @@ public class LearningPathController( ILearningPathService learningPathService, SubscriptionAccessService subscriptions, IClaimService claimService, - ILearnerSetupStateService setupStateService) : ControllerBase + ILearnerSetupStateService setupStateService, + LearningPathGenerationTracker generationTracker) : ControllerBase { private static readonly ConcurrentDictionary>> InFlightGenerations = new(); + /// + /// Server-owned budget for one generation. A plan needs one AI call per 30 days (up to 25 for a + /// 730-day plan, each bounded by the provider timeout), so the old fixed 3 minutes cancelled + /// most multi-month plans. Leaving the page never shortens this budget. + /// + private static readonly TimeSpan GenerationBudget = TimeSpan.FromMinutes(10); + private async Task ValidateAiPrerequisiteAsync( int userId, int? requestedTargetLevelId, @@ -122,9 +130,54 @@ public async Task Preview([FromBody] PreviewLearningPathRequest r userId, request?.TargetCertificateLevelId ?? request?.TargetJlptLevelId, cancellationToken); if (prereqError is not null) return prereqError; - var response = await subscriptions.UseAiAsync("learning_path", - () => learningPathService.PreviewLearningPathAsync(request!, cancellationToken), cancellationToken); - return StatusCode((int)response.StatusCode, response); + if (InFlightGenerations.ContainsKey(userId) || + generationTracker.Get(userId).State == LearningPathGenerationStates.Running) + { + var busy = ApiResponse.Fail( + "Riki đang tạo lộ trình cho bạn. Vui lòng đợi lần tạo hiện tại hoàn tất.", + System.Net.HttpStatusCode.Conflict, errorCode: "LEARNING_PATH_GENERATION_IN_PROGRESS", retryable: true); + return StatusCode((int)busy.StatusCode, busy); + } + + // Preview stays bound to the caller's request: leaving the page cancels it and refunds the credit. + generationTracker.Start(userId, "preview", continuesWhenClientLeaves: false); + var operationStarted = false; + try + { + var response = await subscriptions.UseAiAsync("learning_path", + () => + { + operationStarted = true; + return learningPathService.PreviewLearningPathAsync(request!, cancellationToken); + }, + cancellationToken); + RecordOutcome(userId, response, operationStarted); + return StatusCode((int)response.StatusCode, response); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + // UseAiAsync's refund ran before this exception reached us. + generationTracker.Fail(userId, "LEARNING_PATH_CANCELLED", + "Yêu cầu xem trước đã dừng vì bạn rời trang.", creditsPreserved: true); + throw; + } + catch (Exception) + { + generationTracker.Fail(userId, "LEARNING_PATH_UNEXPECTED_ERROR", UnexpectedErrorMessage, creditsPreserved: null); + throw; + } + } + + /// Trạng thái thật của lần tạo lộ trình AI gần nhất trên server (dùng để hiển thị tiến trình và khôi phục sau khi tải lại trang). + /// + /// Chỉ phản ánh công việc server đã thực sự làm: bước hiện tại và số đợt 30 ngày AI đã hoàn tất. + /// Trạng thái nằm trong bộ nhớ của API: khởi động lại server sẽ trả về "idle". + /// + [HttpGet("generation-status")] + public IActionResult GetGenerationStatus() + { + var userId = claimService.GetUserClaim().Id; + return Ok(ApiResponse.Success(generationTracker.Get(userId))); } /// Xác nhận preview và kích hoạt atomically; retry cùng ID trả lại bản ACTIVE. @@ -187,27 +240,59 @@ public async Task Generate( } } + generationTracker.Start(userId, "generate", continuesWhenClientLeaves: true); + var operationStarted = false; + // Detach the AI work from the caller's token: closing the tab, a client timeout or a second + // coalesced caller never aborts it. The server-owned budget is the only cancellation source. + using var serverBudgetCts = new CancellationTokenSource(GenerationBudget); + ApiResponse response; try { - // Detach shared AI generation from caller 1's cancellation token so aborting one tab - // never fails coalesced concurrent callers awaiting the same in-flight task. - using var serverTimeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(10)); - var response = await subscriptions.UseAiAsync("learning_path", - () => learningPathService.GenerateLearningPathAsync(request!, serverTimeoutCts.Token), - serverTimeoutCts.Token); - tcs.TrySetResult(response); - var awaitedResponse = await tcs.Task.WaitAsync(cancellationToken); - return StatusCode((int)awaitedResponse.StatusCode, awaitedResponse); + response = await subscriptions.UseAiAsync("learning_path", + () => + { + operationStarted = true; + return learningPathService.GenerateLearningPathAsync(request!, serverBudgetCts.Token); + }, + serverBudgetCts.Token); + RecordOutcome(userId, response, operationStarted); + } + catch (OperationCanceledException) when (serverBudgetCts.IsCancellationRequested) + { + // UseAiAsync refunds the reservation in its finally block before this exception reaches us; + // a refund failure would have surfaced as a different exception instead. + response = ApiResponse.Fail( + "Riki cần nhiều thời gian hơn dự kiến nên đã dừng lần tạo này. Lộ trình chưa được lưu. Vui lòng thử lại sau ít phút.", + System.Net.HttpStatusCode.GatewayTimeout, errorCode: "LEARNING_PATH_AI_TIMEOUT", retryable: true); + generationTracker.Fail(userId, response.ErrorCode, response.ErrorMessage, creditsPreserved: true); } catch (Exception ex) { + generationTracker.Fail(userId, "LEARNING_PATH_UNEXPECTED_ERROR", UnexpectedErrorMessage, creditsPreserved: null); tcs.TrySetException(ex); + InFlightGenerations.TryRemove(new KeyValuePair>>(userId, tcs.Task)); throw; } - finally + + tcs.TrySetResult(response); + InFlightGenerations.TryRemove(new KeyValuePair>>(userId, tcs.Task)); + return StatusCode((int)response.StatusCode, response); + } + + private const string UnexpectedErrorMessage = "Đã xảy ra lỗi ngoài dự kiến khi tạo lộ trình. Vui lòng thử lại sau."; + + private void RecordOutcome(int userId, ApiResponse response, bool operationStarted) + { + if (response.IsSuccess) { - InFlightGenerations.TryRemove(new KeyValuePair>>(userId, tcs.Task)); + generationTracker.Succeed(userId, response.Result?.PathId); + return; } + + // operationStarted: a credit was reserved (or the feature is free) and UseAiAsync has already + // refunded it before returning this failure. Otherwise no credit was ever taken. + generationTracker.Fail(userId, response.ErrorCode, response.ErrorMessage, + creditsPreserved: operationStarted ? true : null); } } } diff --git a/RikiPath.WebApi/Controllers/LessonProgressController.cs b/RikiPath.WebApi/Controllers/LessonProgressController.cs index f120ff2..e7f60a8 100644 --- a/RikiPath.WebApi/Controllers/LessonProgressController.cs +++ b/RikiPath.WebApi/Controllers/LessonProgressController.cs @@ -93,6 +93,7 @@ public async Task GetLessonDetail(int lessonId, CancellationToken /// Không tìm thấy lesson. /// Lỗi server khi lưu tiến độ. [HttpPatch("lessons/{lessonId:int}/playback-position")] + [RequireFeature(FeatureCodes.LessonsContent)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -121,6 +122,7 @@ public async Task UpdatePlaybackPosition(int lessonId, [FromBody] /// Bài học không tồn tại hoặc không khả dụng. /// Không thể lưu trạng thái hoàn thành. [HttpPost("lessons/{lessonId:int}/complete")] + [RequireFeature(FeatureCodes.LessonsContent)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] @@ -137,6 +139,7 @@ public async Task CompleteLesson( } [HttpPost("lessons/{lessonId:int}/interact")] + [RequireFeature(FeatureCodes.LessonsContent)] public async Task RecordInteraction( int lessonId, CancellationToken cancellationToken) diff --git a/RikiPath.WebApi/Controllers/MockTestController.cs b/RikiPath.WebApi/Controllers/MockTestController.cs index 8d75cb8..cd2fb2a 100644 --- a/RikiPath.WebApi/Controllers/MockTestController.cs +++ b/RikiPath.WebApi/Controllers/MockTestController.cs @@ -230,6 +230,7 @@ public async Task GetActiveAttempt(CancellationToken cancellation /// Chưa xác thực: Thiếu Bearer Token. /// Không có quyền: Token không có role Learner. /// Lỗi server khi tạo attempt. + [RequireFeature(FeatureCodes.PlacementTest)] [HttpPost("placement/start")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status400BadRequest)] diff --git a/RikiPath.WebApi/Controllers/PlacementTestController.cs b/RikiPath.WebApi/Controllers/PlacementTestController.cs index 895a9ec..3b74d08 100644 --- a/RikiPath.WebApi/Controllers/PlacementTestController.cs +++ b/RikiPath.WebApi/Controllers/PlacementTestController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding; using RikiPath.Application.IServices; using RikiPath.Application.Requests.PlacementTests; +using RikiPath.Domain.Enums; namespace RikiPath.WebApi.Controllers { @@ -45,6 +46,7 @@ public async Task GetActiveAttempt(CancellationToken cancellation /// Lưu tự động các lựa chọn mới nhất trong lượt Placement đang làm. [HttpPut("attempts/{attemptId:int}/answers")] + [RequireFeature(FeatureCodes.PlacementTest)] public async Task SavePlacementAnswers( int attemptId, [FromBody] SubmitPlacementTestRequest request, @@ -59,6 +61,7 @@ public async Task SavePlacementAnswers( /// /// Tối đa hai lượt bắt đầu cho mỗi cấp. Gửi RetakeTargetAssessment = true để làm lượt thứ hai sau khi đã có kết quả. [HttpPost("start")] + [RequireFeature(FeatureCodes.PlacementTest)] public async Task StartPlacementTest( [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] StartPlacementTestRequest? request, CancellationToken cancellationToken = default) @@ -71,6 +74,7 @@ public async Task StartPlacementTest( /// Nộp bài kiểm tra đánh giá năng lực đầu vào, tính điểm theo cấp độ JLPT từ snapshot bất biến và đề xuất cấp độ mục tiêu. /// [HttpPost("attempts/{attemptId:int}/submit")] + [RequireFeature(FeatureCodes.PlacementTest)] public async Task SubmitPlacementTest( int attemptId, [FromBody] SubmitPlacementTestRequest request, diff --git a/RikiPath.WebApi/Controllers/PracticeExerciseController.cs b/RikiPath.WebApi/Controllers/PracticeExerciseController.cs index 1800592..ae157e1 100644 --- a/RikiPath.WebApi/Controllers/PracticeExerciseController.cs +++ b/RikiPath.WebApi/Controllers/PracticeExerciseController.cs @@ -2,12 +2,14 @@ using Microsoft.AspNetCore.Mvc; using RikiPath.Application.IServices; using RikiPath.Application.Requests.PracticeExercises; +using RikiPath.Domain.Enums; namespace RikiPath.WebApi.Controllers { [Route("api/[controller]")] [ApiController] [Authorize(Roles = "Learner")] + [RequireFeature(FeatureCodes.PracticeExercises)] public class PracticeExerciseController( IPracticeExerciseService practiceExerciseService, IClaimService claimService) : ControllerBase diff --git a/RikiPath.WebApi/Controllers/SpeechController.cs b/RikiPath.WebApi/Controllers/SpeechController.cs index e2bedb8..3a0a596 100644 --- a/RikiPath.WebApi/Controllers/SpeechController.cs +++ b/RikiPath.WebApi/Controllers/SpeechController.cs @@ -87,6 +87,9 @@ public async Task Grade(IFormFile audioFile, [FromForm] int certi [ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)] public async Task CreateStreamingSession(CancellationToken cancellationToken) { + var access = await subscriptions.EvaluateFeatureAsync(FeatureCodes.AiSpeaking, cancellationToken); + if (!access.Allowed) + return StatusCode((int)access.StatusCode, new { errorCode = access.ErrorCode ?? "AI_CREDIT_REQUIRED", errorMessage = access.Message }); var result = await speechService.CreateStreamingSessionAsync(cancellationToken); return StatusCode(result.StatusCode, result); } diff --git a/RikiPath.WebApi/Program.cs b/RikiPath.WebApi/Program.cs index 2f7fc35..c402ba9 100644 --- a/RikiPath.WebApi/Program.cs +++ b/RikiPath.WebApi/Program.cs @@ -162,7 +162,12 @@ private static void Main(string[] args) ?? builder.Configuration.GetConnectionString("DefaultConnection"); if (string.IsNullOrWhiteSpace(connection)) - throw new InvalidOperationException("Database connection string not configured. Please set ConnectionStrings:DefaultConnection."); + { + if (!EF.IsDesignTime) + throw new InvalidOperationException("Database connection string not configured. Please set ConnectionStrings:DefaultConnection."); + + connection = "Host=rikipath-design-only.invalid;Database=rikipath_design_only"; + } options.UseNpgsql(connection, npgOptions => { @@ -342,6 +347,8 @@ static bool ImplementsInterface(Type type, Type iface) builder.Services.AddOpenAiFeatures(configuration); builder.Services.AddScoped(); + // Process-local record of each learner's running AI learning-path generation (real stages only). + builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -406,12 +413,21 @@ static bool ImplementsInterface(Type type, Type iface) // AuthService phát JWT từ AppSettings.SecretToken; không chấp nhận cấu hình // dự phòng mà dịch vụ đăng nhập không đọc được (sẽ gây HTTP 500 sau startup). var secret = appSettings?.SecretToken?.Value; + byte[] keyBytes; if (string.IsNullOrWhiteSpace(secret)) { - throw new InvalidOperationException("AppSettings:SecretToken:Value is not configured. Configure JWT secret in appsettings."); + if (!EF.IsDesignTime) + throw new InvalidOperationException("AppSettings:SecretToken:Value is not configured. Configure JWT secret in appsettings."); + + // Ephemeral design-time bytes only for EF CLI metadata discovery; runtime startup always rejects missing JWT secrets. + keyBytes = System.Security.Cryptography.RandomNumberGenerator.GetBytes(32); + } + else + { + keyBytes = Encoding.UTF8.GetBytes(secret); } - var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret)); + var key = new SymmetricSecurityKey(keyBytes); builder.Services .AddAuthentication(options => @@ -551,6 +567,15 @@ static bool ImplementsInterface(Type type, Type iface) }); var app = builder.Build(); + if (app.Environment.IsEnvironment("M4E2E")) + { + // The deterministic stub writes real learning-path rows into whatever database this process + // is connected to; make that impossible to miss so stub plans never reach a shared database. + app.Logger.LogWarning( + "M4E2E environment: AI learning paths come from the deterministic test stub, not a real AI model. " + + "Every generated path is test data; run this environment only against a disposable database."); + } + // 10. Middleware Pipeline app.UseForwardedHeaders(); app.UseMiddleware();