From 55eac17271b1035a8d72821aa8d21e502726e39e Mon Sep 17 00:00:00 2001 From: huydinhdevopssoftware Date: Wed, 2 Dec 2026 15:52:08 +0700 Subject: [PATCH] feat: add admin AI config, cohort invitations, and session learning materials --- README.md | 17 + .../Helpers/NotificationSemanticResolver.cs | 38 + RikiPath.Application/Hubs/NotificationHub.cs | 17 +- .../IRepositories/ILessonRepository.cs | 5 + .../IServices/IAdminAiConfigurationService.cs | 11 + .../IServices/ICohortPreparationZipService.cs | 11 + .../ICohortSessionLearningMaterialsService.cs | 13 + .../IGroupEnrollmentEntitlementContract.cs | 1 - .../IServices/ISidebarCounterService.cs | 2 + .../IServices/IStudyCourseService.cs | 10 + RikiPath.Application/IUnitOfWork.cs | 2 + .../AdminAiConfigurationRequest.cs | 14 + .../Requests/StudyCourses/CourseRequests.cs | 11 +- .../AdminAiConfigurationResponse.cs | 13 + .../Responses/AdminDashboardResponse.cs | 2 + .../CohortSessionLearningMaterialsResponse.cs | 57 + .../CohortPreparationZipResponse.cs | 8 + .../Services/AdminDashboardService.cs | 13 +- .../Services/AiUsageQuotaService.cs | 4 +- .../Services/ClassSessionLifecycleService.cs | 3 + .../CohortEnrollmentEntitlementService.cs | 6 +- .../Services/CohortPreparationZipService.cs | 92 + .../CohortSessionLearningMaterialsService.cs | 238 + .../Services/ContentApprovalService.cs | 3 + .../GroupEnrollmentEntitlementContract.cs | 2 - .../MentorAvailabilityReviewService.cs | 7 + .../Services/MentorDiscoveryService.cs | 8 +- .../MentorLearnerSkillProfileService.cs | 8 +- .../Services/MentorTeachingConflictService.cs | 2 +- .../Services/MentorTeachingProposalService.cs | 5 +- .../Services/MockTestService.cs | 346 +- .../Services/NotificationService.cs | 4 + .../Services/PracticeTestService.cs | 142 +- .../Services/SidebarCounterNotifier.cs | 51 +- .../Services/SidebarCounterService.cs | 76 +- .../Services/StudyCohortLifecycleService.cs | 4 +- .../StudyCohortMentorInvitationService.cs | 567 + .../StudyCohortMentorReplacementService.cs | 37 +- .../Services/StudyCohortService.cs | 39 +- .../Services/StudyCohortTransferService.cs | 35 +- .../Services/StudyCourseChangeService.cs | 2 + .../Services/StudyCourseService.cs | 129 +- .../Services/SupabaseFileStorageService.cs | 45 + RikiPath.Domain/AiRuntimeSettings.cs | 13 + .../Entities/AiRuntimeConfiguration.cs | 12 + RikiPath.Domain/Entities/StudyCohort.cs | 4 +- .../Entities/StudyCohortMentorInvitation.cs | 30 + RikiPath.Domain/Entities/StudyCourse.cs | 5 +- RikiPath.Infrastructure/AppDbContext.cs | 4 + .../AiRuntimeConfigurationConfig.cs | 19 + .../StudyCohortMentorInvitationConfig.cs | 33 + .../Configuration/StudyCourseConfig.cs | 2 +- ...ddAdminCohortMentorInvitations.Designer.cs | 14341 +++++++++++++++ ...1081546_AddAdminCohortMentorInvitations.cs | 92 + ...1201132000_MakeCohortsPlanless.Designer.cs | 14332 +++++++++++++++ .../20261201132000_MakeCohortsPlanless.cs | 82 + ...RepairCohortInvitationRevision.Designer.cs | 14332 +++++++++++++++ ...01135156_RepairCohortInvitationRevision.cs | 56 + ...AddAdminAiRuntimeConfiguration.Designer.cs | 14366 ++++++++++++++++ ...01143534_AddAdminAiRuntimeConfiguration.cs | 42 + .../Migrations/AppDbContextModelSnapshot.cs | 158 +- RikiPath.Infrastructure/OpenAiRegistration.cs | 39 +- .../Repositories/LessonRepository.cs | 58 +- .../Services/AiRuntimeConfigurationService.cs | 296 + .../CohortEnrollmentDeadlineService.cs | 3 +- .../Services/StudyCohortLifecycleWorker.cs | 59 +- RikiPath.Infrastructure/UnitOfWork.cs | 4 + .../AdminAiConfigurationController.cs | 31 + .../AdminTeachingProposalController.cs | 20 +- .../CohortPreparationZipController.cs | 39 + ...ohortSessionLearningMaterialsController.cs | 33 + .../MentorTeachingProposalController.cs | 44 +- .../Controllers/StudyCoursesController.cs | 28 +- RikiPath.WebApi/Program.cs | 3 +- tools/verify-migration-readiness.ps1 | 22 +- 75 files changed, 60381 insertions(+), 321 deletions(-) create mode 100644 RikiPath.Application/IServices/IAdminAiConfigurationService.cs create mode 100644 RikiPath.Application/IServices/ICohortPreparationZipService.cs create mode 100644 RikiPath.Application/IServices/ICohortSessionLearningMaterialsService.cs create mode 100644 RikiPath.Application/Requests/AdminConfig/AdminAiConfigurationRequest.cs create mode 100644 RikiPath.Application/Responses/AdminConfig/AdminAiConfigurationResponse.cs create mode 100644 RikiPath.Application/Responses/MentorMeetings/CohortSessionLearningMaterialsResponse.cs create mode 100644 RikiPath.Application/Responses/StudyCourses/CohortPreparationZipResponse.cs create mode 100644 RikiPath.Application/Services/CohortPreparationZipService.cs create mode 100644 RikiPath.Application/Services/CohortSessionLearningMaterialsService.cs create mode 100644 RikiPath.Application/Services/StudyCohortMentorInvitationService.cs create mode 100644 RikiPath.Domain/AiRuntimeSettings.cs create mode 100644 RikiPath.Domain/Entities/AiRuntimeConfiguration.cs create mode 100644 RikiPath.Domain/Entities/StudyCohortMentorInvitation.cs create mode 100644 RikiPath.Infrastructure/Configuration/AiRuntimeConfigurationConfig.cs create mode 100644 RikiPath.Infrastructure/Configuration/StudyCohortMentorInvitationConfig.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.Designer.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.Designer.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.Designer.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.Designer.cs create mode 100644 RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.cs create mode 100644 RikiPath.Infrastructure/Services/AiRuntimeConfigurationService.cs create mode 100644 RikiPath.WebApi/Controllers/AdminAiConfigurationController.cs create mode 100644 RikiPath.WebApi/Controllers/CohortPreparationZipController.cs create mode 100644 RikiPath.WebApi/Controllers/CohortSessionLearningMaterialsController.cs diff --git a/README.md b/README.md index 369a2399..a87731c6 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,25 @@ Legacy minimum-enrollment/preparation fields remain in stored policy revisions f - When the Mentor explicitly ends the final required valid session, the class lock protects automatic class/enrollment completion and review eligibility. All required sessions and roster attendance must be completed; no Admin confirmation, homework completion, feedback, review or complaint is required. No background time-skip operation writes attendance or completes classes. - Direct attendance does not require Meeting joins. A started class session permits early room access, direct attendance and homework. Absent and ExcusedAbsent are valid final attendance; no attendance/grade is generated automatically. Homework due dates and submission policies remain independent. - Before release, verify build/analyzers and offline model parity; rehearse this migration on clean and representative isolated QA databases with a verified backup. No migration is applied by startup. Server migration, restart and deployment each require separate approval. Export lifecycle evidence before any approved rollback because Down removes the new fields. + +## Admin-created cohorts and mentor invitations + +- Admin creates a draft class and its future session times through `POST /api/study-courses/cohorts`; `POST /api/study-courses/cohorts/mentor-candidates` returns verified mentors qualified for the plan level and free in every selected slot. The database stores each mentor offer in `StudyCohortMentorInvitations`, preserving decline, acceptance and reassignment history. `POST /api/study-courses/cohorts/{cohortId}/mentor-invitations` can invite the next eligible mentor after a decline. +- The invited mentor can list their offers at `GET /api/study-courses/cohort-mentor-invitations`, then accept or decline. Decline requires a reason. Acceptance rechecks teaching level and schedule conflicts, approves the cohort session slots and changes the cohort from `Draft` to `Published`; learners can discover and enroll only after that transition. Admin receives outbox notifications for acceptance, decline and mentor change requests. +- FE flow: call `POST /api/study-courses/cohorts/mentor-candidates` with `{ "planId": 1, "sessions": [{ "startsAtUtc": "2027-01-01T02:00:00Z", "endsAtUtc": "2027-01-01T03:00:00Z" }] }` (provide every session required by the plan). Then call `POST /api/study-courses/cohorts` with the same `planId` and `sessions`, plus `name`, chosen `mentorId` and a new `idempotencyKey` UUID. The response gives `cohortId` and `invitationId`. Mentor lists invitations and calls `POST /api/study-courses/cohort-mentor-invitations/{invitationId}/accept` or `/decline` with `{ "reason": "..." }`. The invitation response includes its status, session times and `cohortRevisionAtInvite`; after a decline, Admin selects another mentor and calls `POST /api/study-courses/cohorts/{cohortId}/mentor-invitations` with `mentorId`, `reason`, a new UUID and the current `expectedCohortRevision`. A changed class schedule invalidates an outstanding invitation; Admin must cancel and resend it. +- For an active cohort, mentor schedule changes go to `POST /api/study-courses/cohorts/{cohortId}/mentor-change-requests`; Admin invites a replacement and the new mentor must accept before future sessions move. Learners request a class transfer through the existing `/{courseId}/transfer-requests` workflow; Admin chooses/approves the destination and the learner's enrollment is moved in one transaction. Per-session learner/mentor changes to group classes are rejected. +- Mentor-authored teaching proposal submission/open-enrollment and Admin proposal approval endpoints return `409 MENTOR_SELF_SCHEDULING_CLOSED`. `StudyCohortMentorInvitations` is added by migration `20261201081546_AddAdminCohortMentorInvitations`; it is additive and its Down refuses to discard invitation history. Do not apply it to Shared Supabase from a feature branch; follow the isolated QA and release preflight above. +- Migration `20261201132000_MakeCohortsPlanless` stores the learner-facing `StudyCohort.Level`, backfills level and missing class tuition from historical plans, removes `StudyCohorts.PlanId`, and makes `StudyCourses.PlanId` nullable for direct class enrollment. Historical course orders retain their existing plan references and payment snapshots. Its Down refuses rollback because a new class cannot be mapped back to a plan. The Admin sets class tuition directly; learner enrollment pays that exact class price through PayOS. Review the generated SQL and rehearse on an isolated database before deployment; startup never applies this migration. +- Migration `20261201135156_RepairCohortInvitationRevision` repairs a database where the invitation migration is recorded as applied but `StudyCohortMentorInvitations.CohortRevisionAtInvite` is absent. It adds the required integer column only when the invitation table is empty, verifies its type and nullability, and leaves correct databases unchanged. A populated incomplete table requires manual review because the original invite-time revision cannot be reconstructed safely. The read-only preflight checks this column when the original migration is marked applied. Rehearse and obtain the normal shared database approval before applying the repair; the migration is never applied at startup. - The operator will review each Stage through the UI after deployment. Full automated end-to-end acceptance is not a prerequisite for this handoff. Migration rehearsal already succeeded on a clean isolated database (25 migrations, including idempotent replay) and a restored local-data clone (76 to 77 history rows); existing class, enrollment, schedule and attendance fingerprints were preserved. The clone's 22 unresolved historical sessions retained null lifecycle status and actual timestamps. Server identity/history and backup/restore still require preflight before an approved server migration. +## Admin AI configuration + +- `GET /api/admin/ai-configuration` returns the active models, provider endpoints, timeouts, token limits and per-user quotas. It reports whether each provider key is set, but never returns a key. +- `PUT /api/admin/ai-configuration` saves the complete editable configuration. Send the `revision` returned by GET as `expectedRevision`; the OpenAI key can be supplied in `settings.OpenAI.ApiKey` alongside `BaseUrl`, all six feature models, timeout and token limits, as in the server configuration shape. OpenRouter accepts `openRouterApiKey` and Gemini accepts up to two `geminiApiKeys`. Empty key fields keep existing keys. Use the matching `clear...ApiKey` flag to remove one. The API accepts Admin only, validates provider URLs and limits, rejects stale revisions with `409`, protects keys with ASP.NET Data Protection and records non-secret before/after values in `AdminAuditLogs`. +- AI clients read the live configuration from an in-process cache and refresh it from the database every 15 seconds. The instance that saves a change applies it immediately. Until the first database configuration exists, settings fall back to appsettings/environment values. +- Migration `20261201143534_AddAdminAiRuntimeConfiguration` creates the singleton `AiRuntimeConfigurations` row store on the first Admin save. Startup never applies this migration. Back up and retain the ASP.NET Data Protection key ring across restarts (and share it between API instances); configure `AiConfiguration:DataProtectionKeysPath` to a persistent path when the deployment does not retain the default key directory. Losing the key ring prevents decryption of saved provider keys. + ## Core Safety Rules 1. **Never run migrations against an unverified database target.** diff --git a/RikiPath.Application/Helpers/NotificationSemanticResolver.cs b/RikiPath.Application/Helpers/NotificationSemanticResolver.cs index c58a5605..9773ded9 100644 --- a/RikiPath.Application/Helpers/NotificationSemanticResolver.cs +++ b/RikiPath.Application/Helpers/NotificationSemanticResolver.cs @@ -49,6 +49,7 @@ private sealed class LiveEntitySnapshot public Dictionary ComplaintStates { get; } = []; public Dictionary TransferStatuses { get; } = []; public Dictionary CohortScheduleStatuses { get; } = []; + public Dictionary CohortMentorInvitationStatuses { get; } = []; public Dictionary PendingCourseScheduleRequestsByCourse { get; } = []; public int PendingPaymentReviewsCount { get; set; } public int PendingContentApprovalsCount { get; set; } @@ -74,6 +75,8 @@ private sealed class LiveEntitySnapshot "LearningFeedbackPending", "CohortTransfer", "CohortScheduleRequest", + "CohortMentorInvitation", + "CohortMentorChange", "CohortPaymentReconciliation", "CourseScheduleRequest", "PaymentReview", @@ -678,6 +681,27 @@ private static SemanticResolution ResolveCore( return new SemanticResolution(CategoryInfo, false, null); } + if (string.Equals(type, "CohortMentorInvitation", StringComparison.OrdinalIgnoreCase) + || string.Equals(type, "CohortMentorChange", StringComparison.OrdinalIgnoreCase)) + { + var invitationId = ExtractQueryInt(link, "invitationId"); + var status = invitationId.HasValue && snapshot is not null + ? snapshot.CohortMentorInvitationStatuses.GetValueOrDefault(invitationId.Value) + : null; + var actionable = recipientRole == Role.Mentor + ? snapshot is null ? status is null or StudyCohortMentorInvitation.Pending : status == StudyCohortMentorInvitation.Pending + : status is StudyCohortMentorInvitation.Declined or StudyCohortMentorInvitation.ChangeRequested + || (snapshot is null && (string.Equals(type, "CohortMentorChange", StringComparison.OrdinalIgnoreCase) + || titleLower.Contains("từ chối", StringComparison.Ordinal))); + if (status is StudyCohortMentorInvitation.Accepted or StudyCohortMentorInvitation.Replaced + or StudyCohortMentorInvitation.Cancelled) + actionable = false; + var exists = status is not null || snapshot is null; + return new SemanticResolution(actionable ? CategoryWarning : CategoryInfo, actionable, + actionable ? ActionPending : ActionResolved, "CohortMentorInvitation", invitationId, + status, actionable ? "Chờ xử lý" : "Đã xử lý", exists); + } + // 10. Cohort Schedule Request & Payment Reconciliation if (string.Equals(type, "CohortScheduleRequest", StringComparison.OrdinalIgnoreCase)) { @@ -1042,6 +1066,7 @@ private static async Task LoadLiveSnapshotAsync( var feedbackIds = new HashSet(); var transferIds = new HashSet(); var cohortScheduleIds = new HashSet(); + var cohortMentorInvitationIds = new HashSet(); var homeworkAssignmentIds = new HashSet(); var homeworkGroupKeys = new HashSet(); @@ -1067,6 +1092,9 @@ private static async Task LoadLiveSnapshotAsync( if (type == "LearningFeedbackPending") TryAdd(feedbackIds, ExtractQueryInt(link, "feedbackId")); TryAdd(transferIds, ExtractQueryInt(link, "transferRequestId")); TryAdd(cohortScheduleIds, ExtractQueryInt(link, "cohortScheduleRequestId")); + if (string.Equals(type, "CohortMentorInvitation", StringComparison.OrdinalIgnoreCase) + || string.Equals(type, "CohortMentorChange", StringComparison.OrdinalIgnoreCase)) + TryAdd(cohortMentorInvitationIds, ExtractQueryInt(link, "invitationId")); TryAdd(mentorIds, ExtractQueryInt(link, "mentorId")); if (linkLower.StartsWith("/admin/payments", StringComparison.Ordinal) @@ -1251,6 +1279,16 @@ private static async Task LoadLiveSnapshotAsync( snapshot.CohortScheduleStatuses[r.Id] = (r.Status, r.Kind); } + if (cohortMentorInvitationIds.Count > 0) + { + var rows = await unitOfWork.StudyCohortMentorInvitations.Query().AsNoTracking() + .Where(x => cohortMentorInvitationIds.Contains(x.Id) + && (snapshot.RecipientRole == Role.Admin || x.MentorId == userId)) + .Select(x => new { x.Id, x.Status }).ToListAsync(ct); + foreach (var row in rows) + snapshot.CohortMentorInvitationStatuses[row.Id] = row.Status; + } + if (checkPendingContent) { var pendingReq = await unitOfWork.ContentApprovalRequests.Query().AsNoTracking() diff --git a/RikiPath.Application/Hubs/NotificationHub.cs b/RikiPath.Application/Hubs/NotificationHub.cs index 7c042dd1..7f8941e7 100644 --- a/RikiPath.Application/Hubs/NotificationHub.cs +++ b/RikiPath.Application/Hubs/NotificationHub.cs @@ -4,11 +4,13 @@ using Microsoft.EntityFrameworkCore; using RikiPath.Application.Common; using RikiPath.Application.Helpers; +using RikiPath.Application.IServices; +using RikiPath.Domain.Enums; namespace RikiPath.Application.Hubs; [Authorize] -public class NotificationHub(IUnitOfWork? unitOfWork = null) : Hub +public class NotificationHub(IUnitOfWork? unitOfWork = null, ISidebarCounterService? sidebarCounters = null) : Hub { public override async Task OnConnectedAsync() { @@ -40,6 +42,19 @@ public async Task RequestSync() } } + public async Task RequestSidebarCounters() + { + var userId = TryGetUserId(); + var rawRole = Context.User?.FindFirst(ClaimTypes.Role)?.Value; + if (userId is not int id || !Enum.TryParse(rawRole, true, out var role) || sidebarCounters is null) + return; + + var result = await sidebarCounters.GetForUserAsync(id, role, Context.ConnectionAborted); + if (result.IsSuccess && result.Result is not null) + await Clients.Caller.SendAsync("SidebarCountersChanged", + new { Reason = "sync", Snapshot = result.Result }, Context.ConnectionAborted); + } + private async Task PushCountsToCallerAsync(int userId) { if (unitOfWork is null) return; diff --git a/RikiPath.Application/IRepositories/ILessonRepository.cs b/RikiPath.Application/IRepositories/ILessonRepository.cs index 8fc29f18..b6a3fcc3 100644 --- a/RikiPath.Application/IRepositories/ILessonRepository.cs +++ b/RikiPath.Application/IRepositories/ILessonRepository.cs @@ -18,8 +18,13 @@ Task> GetAssessmentRoadmapLessonsAsync( Task GetLearnerVisibleByIdAsync( int lessonId, CancellationToken cancellationToken = default); + Task> GetLearnerVisibleByIdsAsync( + IReadOnlyCollection lessonIds, + CancellationToken cancellationToken = default); Task<(int Total, int Completed)> GetCompletionStatsAsync(int userId); Task> GetByCertificateLevelAsync(int certificateLevelId, CancellationToken cancellationToken = default); + Task<(int Total, Lesson? Lesson)> GetByCertificateLevelPositionAsync( + int certificateLevelId, int zeroBasedPosition, CancellationToken cancellationToken = default); } public sealed record AssessmentRoadmapLesson( diff --git a/RikiPath.Application/IServices/IAdminAiConfigurationService.cs b/RikiPath.Application/IServices/IAdminAiConfigurationService.cs new file mode 100644 index 00000000..7445ac8c --- /dev/null +++ b/RikiPath.Application/IServices/IAdminAiConfigurationService.cs @@ -0,0 +1,11 @@ +using RikiPath.Application.Requests.AdminConfig; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.AdminConfig; + +namespace RikiPath.Application.IServices; + +public interface IAdminAiConfigurationService +{ + Task> GetAsync(CancellationToken ct); + Task> UpdateAsync(AdminAiConfigurationRequest request, int adminId, CancellationToken ct); +} diff --git a/RikiPath.Application/IServices/ICohortPreparationZipService.cs b/RikiPath.Application/IServices/ICohortPreparationZipService.cs new file mode 100644 index 00000000..e11d70cf --- /dev/null +++ b/RikiPath.Application/IServices/ICohortPreparationZipService.cs @@ -0,0 +1,11 @@ +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.StudyCourses; + +namespace RikiPath.Application.IServices; + +public interface ICohortPreparationZipService +{ + Task> UploadAsync(int cohortId, Stream content, + CancellationToken ct = default); + Task> GetAsync(int cohortId, CancellationToken ct = default); +} diff --git a/RikiPath.Application/IServices/ICohortSessionLearningMaterialsService.cs b/RikiPath.Application/IServices/ICohortSessionLearningMaterialsService.cs new file mode 100644 index 00000000..ceda5797 --- /dev/null +++ b/RikiPath.Application/IServices/ICohortSessionLearningMaterialsService.cs @@ -0,0 +1,13 @@ +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.MentorMeetings; + +namespace RikiPath.Application.IServices; + +public interface ICohortSessionLearningMaterialsService +{ + Task> GetAsync( + int cohortId, int sessionId, CancellationToken ct = default); + Task> PrepareAsync( + int cohortId, int sessionId, IReadOnlyList lessonIds, CancellationToken ct = default); + Task HasPreparedAsync(int cohortId, int sessionId, CancellationToken ct = default); +} diff --git a/RikiPath.Application/IServices/IGroupEnrollmentEntitlementContract.cs b/RikiPath.Application/IServices/IGroupEnrollmentEntitlementContract.cs index 5bde326a..fba30e50 100644 --- a/RikiPath.Application/IServices/IGroupEnrollmentEntitlementContract.cs +++ b/RikiPath.Application/IServices/IGroupEnrollmentEntitlementContract.cs @@ -16,7 +16,6 @@ public interface IGroupEnrollmentEntitlementContract { GroupEnrollmentEntitlementDecision EvaluateGroupEnrollment( StudyCohort cohort, - StudyCoursePlan plan, int learnerId, string? entitlementReference); } diff --git a/RikiPath.Application/IServices/ISidebarCounterService.cs b/RikiPath.Application/IServices/ISidebarCounterService.cs index c2c40ff4..8202678b 100644 --- a/RikiPath.Application/IServices/ISidebarCounterService.cs +++ b/RikiPath.Application/IServices/ISidebarCounterService.cs @@ -1,9 +1,11 @@ using RikiPath.Application.Responses; using RikiPath.Application.Responses.Sidebar; +using RikiPath.Domain.Enums; namespace RikiPath.Application.IServices; public interface ISidebarCounterService { Task> GetMyCountersAsync(CancellationToken cancellationToken = default); + Task> GetForUserAsync(int userId, Role role, CancellationToken cancellationToken = default); } diff --git a/RikiPath.Application/IServices/IStudyCourseService.cs b/RikiPath.Application/IServices/IStudyCourseService.cs index 9d981009..7675d681 100644 --- a/RikiPath.Application/IServices/IStudyCourseService.cs +++ b/RikiPath.Application/IServices/IStudyCourseService.cs @@ -18,6 +18,14 @@ public interface IStudyCourseService // Tìm lớp nhóm theo Mentor, cấp độ, cường độ, thứ và khung giờ (giờ Việt Nam). Task> CohortsAsync(CohortDiscoveryFilter? filter, CancellationToken ct); Task> SaveCohortAsync(int? id, SaveStudyCohort request, CancellationToken ct); + Task> CreateAdminCohortAsync(CreateAdminCohortRequest request, CancellationToken ct); + Task> AdminCohortMentorCandidatesAsync(AdminCohortMentorCandidatesRequest request, CancellationToken ct); + Task> CohortMentorInvitationsAsync(int? cohortId, CancellationToken ct); + Task> InviteCohortMentorAsync(int cohortId, InviteCohortMentorRequest request, CancellationToken ct); + Task> AcceptCohortMentorInvitationAsync(int invitationId, CancellationToken ct); + Task> DeclineCohortMentorInvitationAsync(int invitationId, DeclineCohortInvitationRequest request, CancellationToken ct); + Task> CancelCohortMentorInvitationAsync(int invitationId, CancellationToken ct); + Task> RequestCohortMentorChangeAsync(int cohortId, RequestCohortMentorChangeRequest request, CancellationToken ct); // Admin xem trước xung đột lịch dạy của Mentor cho các khung giờ đã chọn (không ghi dữ liệu). Task> CohortSchedulePreviewAsync(CohortSchedulePreviewRequest request, CancellationToken ct); Task> CatalogAsync(CancellationToken ct); @@ -36,6 +44,8 @@ public interface IStudyCourseService Task> CancelPendingEnrollmentAsync(int id, CancellationToken ct); Task> CancelCohortEnrollmentAsync(int id, CancelCohortEnrollmentRequest? request, CancellationToken ct); Task> ConfirmPaymentAsync(int courseId, PaymentCallbackResult callback, string? reference, CancellationToken ct); + // Chỉ gọi nội bộ sau khi backend đã truy vấn trực tiếp trạng thái đơn từ PayOS. + Task> ConfirmVerifiedPaymentStatusAsync(int courseId, PaymentLinkInformation info, CancellationToken ct); Task> ReconcileCoursePaymentAsync(int courseId, CancellationToken ct); Task> AttendanceAsync(int id, int sessionId, ConfirmCourseAttendance request, CancellationToken ct); Task> CompleteAsync(int id, CancellationToken ct); diff --git a/RikiPath.Application/IUnitOfWork.cs b/RikiPath.Application/IUnitOfWork.cs index 469ec16b..306ebf75 100644 --- a/RikiPath.Application/IUnitOfWork.cs +++ b/RikiPath.Application/IUnitOfWork.cs @@ -104,6 +104,7 @@ public interface IUnitOfWork IGenericRepository CourseScheduleRequests { get; } IGenericRepository CohortTransferRequests { get; } IGenericRepository StudyCohortMentorAssignments { get; } + IGenericRepository StudyCohortMentorInvitations { get; } IGenericRepository CohortScheduleRequests { get; } IGenericRepository CohortMentorReviews { get; } IGenericRepository CohortComplaints { get; } @@ -113,6 +114,7 @@ public interface IUnitOfWork // Db Helpers Task SaveChangesAsync(CancellationToken cancellationToken = default); + void ClearTrackedEntities(); Task ExecuteInTransactionAsync( Func operation, CancellationToken cancellationToken = default); diff --git a/RikiPath.Application/Requests/AdminConfig/AdminAiConfigurationRequest.cs b/RikiPath.Application/Requests/AdminConfig/AdminAiConfigurationRequest.cs new file mode 100644 index 00000000..aa07b4fc --- /dev/null +++ b/RikiPath.Application/Requests/AdminConfig/AdminAiConfigurationRequest.cs @@ -0,0 +1,14 @@ +using RikiPath.Domain; + +namespace RikiPath.Application.Requests.AdminConfig; + +public sealed record AdminAiConfigurationRequest( + AiRuntimeSettings Settings, + int ExpectedRevision, + string? OpenAiApiKey = null, + bool ClearOpenAiApiKey = false, + string? OpenRouterApiKey = null, + bool ClearOpenRouterApiKey = false, + IReadOnlyList? GeminiApiKeys = null, + bool ClearGeminiApiKeys = false, + string? Reason = null); diff --git a/RikiPath.Application/Requests/StudyCourses/CourseRequests.cs b/RikiPath.Application/Requests/StudyCourses/CourseRequests.cs index 46190f75..92b7ab77 100644 --- a/RikiPath.Application/Requests/StudyCourses/CourseRequests.cs +++ b/RikiPath.Application/Requests/StudyCourses/CourseRequests.cs @@ -3,7 +3,7 @@ namespace RikiPath.Application.Requests.StudyCourses; public sealed record SaveCoursePlan(string Name, int CertificateLevelId, int DurationMonths, int SessionsPerWeek, int? SessionMinutes, int? TotalSessions, int? RetakeClaimDays, decimal Price, bool IsPublished, int Revision = 1, string SessionType = "Individual", int Capacity = 1, DateTime? TargetExamDate = null); -public sealed record PurchaseCourse(int PlanId, Guid IdempotencyKey, int? CohortId = null, string? EntitlementReference = null); +public sealed record PurchaseCourse(int? PlanId, Guid IdempotencyKey, int? CohortId = null, string? EntitlementReference = null); public sealed record EnrollCohortRequest(Guid IdempotencyKey, string? EntitlementReference = null); public sealed record CancelCohortEnrollmentRequest(string? Reason = null); public sealed record ActivateCourse(int MentorId, DateTime StartsAt); @@ -23,6 +23,15 @@ public sealed record GrantCohortEntitlementRequest(int LearnerId, string SourceT public sealed record RevokeCohortEntitlementRequest(string Reason); public sealed record SaveStudyCohort(int PlanId, string Name, int MentorId, int Capacity, List AvailabilityIds, bool Publish, int Revision = 1, int? SourceProposalId = null); +public sealed record AdminCohortSessionTime(DateTime StartsAtUtc, DateTime EndsAtUtc); +public sealed record CreateAdminCohortRequest(string Name, string Level, int MentorId, int Capacity, decimal Price, + int CourseDurationWeeks, IReadOnlyList Sessions, Guid IdempotencyKey, + DateTime? EnrollmentClosesAtUtc = null); +public sealed record AdminCohortMentorCandidatesRequest(string Level, IReadOnlyList Sessions); +public sealed record InviteCohortMentorRequest(int MentorId, string Reason, Guid IdempotencyKey, + int ExpectedCohortRevision, int? FromSessionNumber = null); +public sealed record DeclineCohortInvitationRequest(string Reason); +public sealed record RequestCohortMentorChangeRequest(string Reason); // Xem trước xung đột lịch dạy khi Admin chọn khung giờ cho lớp (chỉ tham khảo; lưu lớp vẫn kiểm tra lại). public sealed record CohortSchedulePreviewRequest(int MentorId, List AvailabilityIds, int? CohortId = null); // Bộ lọc tìm lớp nhóm: Mentor, cấp độ JLPT, tần suất học (số buổi/tuần hoặc intensity cũ), thứ (0=Chủ nhật..6, giờ Việt Nam) diff --git a/RikiPath.Application/Responses/AdminConfig/AdminAiConfigurationResponse.cs b/RikiPath.Application/Responses/AdminConfig/AdminAiConfigurationResponse.cs new file mode 100644 index 00000000..10a17006 --- /dev/null +++ b/RikiPath.Application/Responses/AdminConfig/AdminAiConfigurationResponse.cs @@ -0,0 +1,13 @@ +using RikiPath.Domain; + +namespace RikiPath.Application.Responses.AdminConfig; + +public sealed record AdminAiConfigurationResponse( + AiRuntimeSettings Settings, + bool OpenAiKeyConfigured, + bool OpenRouterKeyConfigured, + int GeminiKeyCount, + int Revision, + DateTime? UpdatedAtUtc, + int? UpdatedByAdminId, + string Source); diff --git a/RikiPath.Application/Responses/AdminDashboardResponse.cs b/RikiPath.Application/Responses/AdminDashboardResponse.cs index b05291e5..94e9d7dc 100644 --- a/RikiPath.Application/Responses/AdminDashboardResponse.cs +++ b/RikiPath.Application/Responses/AdminDashboardResponse.cs @@ -40,6 +40,8 @@ public sealed class AdminDashboardResponse public int PendingContent { get; init; } public int PendingMentorSchedules { get; init; } public int PendingTeachingProposals { get; init; } + public int PendingCohortMentorInvitations { get; init; } + public int CohortMentorChangeRequests { get; init; } public int PendingVerifications { get; init; } public int PendingSlotCancelRequests { get; init; } public int PendingSlotChangeRequests { get; init; } diff --git a/RikiPath.Application/Responses/MentorMeetings/CohortSessionLearningMaterialsResponse.cs b/RikiPath.Application/Responses/MentorMeetings/CohortSessionLearningMaterialsResponse.cs new file mode 100644 index 00000000..d7ad7838 --- /dev/null +++ b/RikiPath.Application/Responses/MentorMeetings/CohortSessionLearningMaterialsResponse.cs @@ -0,0 +1,57 @@ +namespace RikiPath.Application.Responses.MentorMeetings; + +public sealed record CohortSessionLearningMaterialsResponse( + int CohortId, + string CohortName, + string Level, + int SessionId, + int SessionNumber, + int CurriculumPosition, + int LessonsAvailableForLevel, + CohortLessonLearningMaterialResponse? Lesson, + IReadOnlyList SuggestedLessons, + IReadOnlyList SelectedLessons, + bool IsPrepared, + bool CanEdit); + +public sealed record CohortLessonSuggestionResponse( + int Id, string Title, string? Description, int SortOrder, int EstimatedMinutes, + string LanguageSkill, string? Topic, int KanjiCount, int VocabularyCount, int GrammarCount); + +public sealed record CohortLessonLearningMaterialResponse( + int Id, + string Title, + string? Description, + string? LearningObjectives, + int EstimatedMinutes, + int SortOrder, + string LanguageSkill, + string? Topic, + IReadOnlyList Kanji, + IReadOnlyList Vocabulary, + IReadOnlyList Grammar); + +public sealed record CohortLessonKanjiResponse( + int Id, + string Character, + string Meaning, + string? SinoVietnamese, + string? OnYomi, + string? KunYomi, + int StrokeCount); + +public sealed record CohortLessonVocabularyResponse( + int Id, + string Word, + string Reading, + string Meaning, + string? ExampleSentence, + string? ExampleSentenceMeaning); + +public sealed record CohortLessonGrammarResponse( + int Id, + string Title, + string Structure, + string? UsageNotes, + string? ExampleSentence, + string? ExampleSentenceMeaning); diff --git a/RikiPath.Application/Responses/StudyCourses/CohortPreparationZipResponse.cs b/RikiPath.Application/Responses/StudyCourses/CohortPreparationZipResponse.cs new file mode 100644 index 00000000..9e175429 --- /dev/null +++ b/RikiPath.Application/Responses/StudyCourses/CohortPreparationZipResponse.cs @@ -0,0 +1,8 @@ +namespace RikiPath.Application.Responses.StudyCourses; + +public sealed record CohortPreparationZipResponse( + int CohortId, + string FileName, + string DownloadUrl, + DateTime ExpiresAtUtc, + string? StorageUrl = null); diff --git a/RikiPath.Application/Services/AdminDashboardService.cs b/RikiPath.Application/Services/AdminDashboardService.cs index c9a3f864..98b4feea 100644 --- a/RikiPath.Application/Services/AdminDashboardService.cs +++ b/RikiPath.Application/Services/AdminDashboardService.cs @@ -23,9 +23,14 @@ public async Task> GetAsync(CancellationToke var pendingContent = await unitOfWork.ContentApprovalRequests.Query() .CountAsync(x => !x.IsDeleted && x.Status == ContentApprovalStatus.PendingReview, cancellationToken); var pendingMentorSchedules = await unitOfWork.MentorAvailabilities.Query() - .CountAsync(x => !x.IsDeleted && !x.IsApproved && x.RejectedAt == null && x.TeachingProposalId == null && x.StartTime > now, cancellationToken); - var pendingTeachingProposals = await unitOfWork.MentorTeachingProposals.Query() - .CountAsync(x => x.Status == MentorTeachingProposalStatus.PendingReview, cancellationToken); + .CountAsync(x => !x.IsDeleted && !x.IsApproved && x.RejectedAt == null && x.TeachingProposalId == null && x.StartTime > now + && !unitOfWork.StudyCohorts.Query().Any(c => c.Sessions.Any(s => s.AvailabilityId == x.Id)), cancellationToken); + var pendingTeachingProposals = 0; + var pendingCohortMentorInvitations = await unitOfWork.StudyCohortMentorInvitations.Query() + .CountAsync(x => x.Status == StudyCohortMentorInvitation.Pending, cancellationToken); + var cohortMentorChangeRequests = await unitOfWork.StudyCohortMentorInvitations.Query() + .CountAsync(x => x.Status == StudyCohortMentorInvitation.ChangeRequested + || (x.Status == StudyCohortMentorInvitation.Declined && x.Cohort.Status == "Draft"), cancellationToken); var pendingVerifications = await unitOfWork.MentorProfiles.Query() .CountAsync(x => !x.IsDeleted && x.VerificationStatus == MentorVerificationStatus.Pending && !x.Mentor.IsDeleted, cancellationToken); @@ -169,6 +174,8 @@ DateOnly ToVnDay(DateTime dt) PendingContent = pendingContent, PendingMentorSchedules = pendingMentorSchedules, PendingTeachingProposals = pendingTeachingProposals, + PendingCohortMentorInvitations = pendingCohortMentorInvitations, + CohortMentorChangeRequests = cohortMentorChangeRequests, PendingVerifications = pendingVerifications, PendingSlotCancelRequests = pendingSlotCancelRequests, PendingSlotChangeRequests = pendingSlotChangeRequests, diff --git a/RikiPath.Application/Services/AiUsageQuotaService.cs b/RikiPath.Application/Services/AiUsageQuotaService.cs index 128d532e..36275138 100644 --- a/RikiPath.Application/Services/AiUsageQuotaService.cs +++ b/RikiPath.Application/Services/AiUsageQuotaService.cs @@ -36,9 +36,7 @@ public AiUsageQuotaService( var primary = aiSettings?.Value?.RateLimit; var fallback = appSettings?.Value?.Ai?.RateLimit; // Program.cs binds section "Ai" to IOptions, whereas legacy deployments may nest under "AppSettings:Ai". - _limits = (primary is not null && (primary.MaxRequestsPerUserPerDay != 20 || primary.MaxTokensPerUserPerDay != 50000 || fallback is null)) - ? primary - : (fallback ?? new AiRateLimitSettings()); + _limits = primary ?? fallback ?? new AiRateLimitSettings(); _translationLimits = translationSettings?.Value ?? new TranslationSettings(); } diff --git a/RikiPath.Application/Services/ClassSessionLifecycleService.cs b/RikiPath.Application/Services/ClassSessionLifecycleService.cs index 1571de4e..e0426a79 100644 --- a/RikiPath.Application/Services/ClassSessionLifecycleService.cs +++ b/RikiPath.Application/Services/ClassSessionLifecycleService.cs @@ -11,6 +11,7 @@ namespace RikiPath.Application.Services; public sealed class ClassSessionLifecycleService(IUnitOfWork uow, IClaimService claims, ICohortEnrollmentDeadlineService deadlines, + ICohortSessionLearningMaterialsService learningMaterials, ISidebarCounterNotifier? counters = null) : IClassSessionLifecycleService { private sealed class LifecycleConflict(string message) : Exception(message); @@ -201,6 +202,8 @@ await uow.ExecuteInTransactionAsync(async token => result = new { session.Id, session.Status }; return; } + if (!await learningMaterials.HasPreparedAsync(cohortId, sessionId, token)) + throw new LifecycleConflict("Giáo viên cần chọn bài học trước khi bắt đầu buổi học."); if (session.Status != "InProgress") { // Legacy data (class closed before auto-open existed): open through the shared rule, never out of order. diff --git a/RikiPath.Application/Services/CohortEnrollmentEntitlementService.cs b/RikiPath.Application/Services/CohortEnrollmentEntitlementService.cs index 89781529..fa376830 100644 --- a/RikiPath.Application/Services/CohortEnrollmentEntitlementService.cs +++ b/RikiPath.Application/Services/CohortEnrollmentEntitlementService.cs @@ -61,7 +61,6 @@ public async Task> GrantAsync( var cohort = await uow.StudyCohorts.Query() .AsNoTracking() - .Include(x => x.Plan) .SingleOrDefaultAsync(x => x.Id == cohortId, ct); if (cohort is null) return ApiResponse.Fail("Không tìm thấy lớp học định kỳ.", HttpStatusCode.NotFound); @@ -101,7 +100,6 @@ public async Task> GrantAsync( var row = new CohortEnrollmentEntitlement { StudyCohortId = cohortId, - PlanId = cohort.PlanId, LearnerId = request.LearnerId, EntitlementReference = reference, SourceType = sourceType, @@ -252,7 +250,7 @@ public async Task> MyEntitlementsAsync(CancellationToken ct) var now = DateTime.UtcNow; var rows = await uow.CohortEnrollmentEntitlements.Query() .AsNoTracking() - .Include(x => x.StudyCohort).ThenInclude(c => c.Plan).ThenInclude(p => p.CertificateLevel) + .Include(x => x.StudyCohort) .Where(x => !x.IsDeleted && x.LearnerId == actor.Id) .OrderByDescending(x => x.Id) .Select(x => new @@ -260,7 +258,7 @@ public async Task> MyEntitlementsAsync(CancellationToken ct) x.Id, x.StudyCohortId, CohortName = x.StudyCohort.Name, - Level = x.StudyCohort.Plan.CertificateLevel.Code, + Level = x.StudyCohort.Level, StartsAt = x.StudyCohort.StartsAt, x.PlanId, x.EntitlementReference, diff --git a/RikiPath.Application/Services/CohortPreparationZipService.cs b/RikiPath.Application/Services/CohortPreparationZipService.cs new file mode 100644 index 00000000..24fc8b8f --- /dev/null +++ b/RikiPath.Application/Services/CohortPreparationZipService.cs @@ -0,0 +1,92 @@ +using System.IO.Compression; +using System.Net; +using Microsoft.EntityFrameworkCore; +using RikiPath.Application.IServices; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.StudyCourses; +using RikiPath.Domain.Enums; + +namespace RikiPath.Application.Services; + +public sealed class CohortPreparationZipService(IUnitOfWork uow, IClaimService claims, + SupabaseFileStorageService storage) : ICohortPreparationZipService +{ + public const long MaxZipBytes = 25L * 1024 * 1024; + private const long MaxExpandedBytes = 250L * 1024 * 1024; + private const int MaxEntries = 500; + + public async Task> UploadAsync(int cohortId, Stream content, + CancellationToken ct = default) + { + var actor = claims.GetUserClaim(); + if (actor.Role != Role.Admin) return ApiResponse.Forbidden(); + var cohort = await uow.StudyCohorts.Query().AsNoTracking() + .Where(c => c.Id == cohortId).Select(c => new { c.Status }).FirstOrDefaultAsync(ct); + if (cohort is null) return ApiResponse.NotFound("Không tìm thấy lớp học."); + if (cohort.Status is "Cancelled" or "Completed") + return ApiResponse.Conflict("Lớp đã kết thúc hoặc bị hủy; không thể cập nhật tài liệu."); + if (!ValidZip(content)) + return ApiResponse.Fail( + "ZIP không hợp lệ, rỗng hoặc vượt giới hạn 25 MB / 500 tệp / 250 MB sau giải nén.", + HttpStatusCode.BadRequest); + content.Position = 0; + var storageUrl = await storage.UploadCohortPreparationZipAsync(cohortId, content, ct); + var downloadUrl = await storage.SignCohortPreparationZipAsync(cohortId, ct); + return ApiResponse.Success(new( + cohortId, FileName(cohortId), downloadUrl, DateTime.UtcNow.AddSeconds(60), storageUrl)); + } + + public async Task> GetAsync(int cohortId, + CancellationToken ct = default) + { + var actor = claims.GetUserClaim(); + var cohort = await uow.StudyCohorts.Query().AsNoTracking() + .Where(c => c.Id == cohortId).Select(c => new { c.MentorId, c.Status }).FirstOrDefaultAsync(ct); + if (cohort is null) return ApiResponse.NotFound("Không tìm thấy lớp học."); + var authorized = actor.Role switch + { + Role.Admin => true, + Role.Mentor => cohort.MentorId == actor.Id, + Role.Learner => cohort.Status is "Published" or "Completed" + && await uow.StudyCourses.Query().AsNoTracking().AnyAsync(c => + c.CohortId == cohortId && c.LearnerId == actor.Id + && (c.PaymentStatus == "Paid" || c.PaymentStatus == "PartiallyRefunded") + && (c.Status == "Ready" || c.Status == "Active" || c.Status == "Completed"), ct), + _ => false + }; + if (!authorized) return ApiResponse.Forbidden("Bạn không có quyền tải tài liệu lớp."); + var downloadUrl = await storage.GetCohortPreparationZipDownloadUrlAsync(cohortId, ct); + if (downloadUrl is null) + return ApiResponse.NotFound("Lớp chưa có ZIP tài liệu chuẩn bị."); + return ApiResponse.Success(new( + cohortId, FileName(cohortId), downloadUrl, DateTime.UtcNow.AddSeconds(60))); + } + + private static string FileName(int cohortId) => $"Tai-lieu-chuan-bi-lop-{cohortId}.zip"; + + private static bool ValidZip(Stream content) + { + if (!content.CanSeek || content.Length is <= 0 or > MaxZipBytes) return false; + try + { + content.Position = 0; + using var archive = new ZipArchive(content, ZipArchiveMode.Read, leaveOpen: true); + var files = 0; + long expandedBytes = 0; + foreach (var entry in archive.Entries) + { + var path = entry.FullName.Replace('\\', '/'); + if (path.StartsWith('/') || Path.IsPathRooted(path) + || path.Split('/').Any(part => part is "." or ".." || part.Contains(':'))) return false; + if (string.IsNullOrEmpty(entry.Name)) continue; + files++; + if (files > MaxEntries || entry.Length < 0 || entry.Length > MaxExpandedBytes) return false; + expandedBytes += entry.Length; + if (expandedBytes > MaxExpandedBytes) return false; + } + return files > 0; + } + catch (InvalidDataException) { return false; } + finally { content.Position = 0; } + } +} diff --git a/RikiPath.Application/Services/CohortSessionLearningMaterialsService.cs b/RikiPath.Application/Services/CohortSessionLearningMaterialsService.cs new file mode 100644 index 00000000..1047e996 --- /dev/null +++ b/RikiPath.Application/Services/CohortSessionLearningMaterialsService.cs @@ -0,0 +1,238 @@ +using System.Net; +using Microsoft.EntityFrameworkCore; +using RikiPath.Application.IServices; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.MentorMeetings; +using RikiPath.Domain.Entities; +using RikiPath.Domain.Enums; + +namespace RikiPath.Application.Services; + +public sealed class CohortSessionLearningMaterialsService( + IUnitOfWork uow, + IClaimService claims) : ICohortSessionLearningMaterialsService +{ + private const int MaxLessons = 10; + private static string PlanAction(int sessionId) => $"CohortSessionLessons:{sessionId}"; + private sealed record SavedPlan(string Detail, int ActorId); + + private Task LatestPlanAsync(int cohortId, int sessionId, CancellationToken ct) + => uow.StudyCourses.Query().AsNoTracking() + .Where(c => c.CohortId == cohortId) + .SelectMany(c => c.Audit.Where(a => a.Action == PlanAction(sessionId))) + .OrderByDescending(a => a.Id).Select(a => new SavedPlan(a.Detail, a.ActorId)).FirstOrDefaultAsync(ct); + + public async Task HasPreparedAsync(int cohortId, int sessionId, CancellationToken ct = default) + { + var plan = await LatestPlanAsync(cohortId, sessionId, ct); + if (string.IsNullOrWhiteSpace(plan?.Detail)) return false; + var ids = plan.Detail.Split(',', StringSplitOptions.RemoveEmptyEntries) + .Select(value => int.TryParse(value, out var id) ? id : 0).Where(id => id > 0).ToArray(); + if (ids.Length is < 1 or > MaxLessons || ids.Distinct().Count() != ids.Length) return false; + var cohort = await uow.StudyCohorts.Query().AsNoTracking().Where(c => c.Id == cohortId) + .Select(c => new { c.Level, c.MentorId }).FirstOrDefaultAsync(ct); + if (cohort is null || cohort.MentorId != plan.ActorId) return false; + var levels = await uow.CertificateLevels.GetLearnerVisibleJlptLevelsAsync(ct); + var level = levels.FirstOrDefault(x => string.Equals(x.Code, cohort.Level, StringComparison.OrdinalIgnoreCase)); + if (level is null) return false; + var count = await uow.Lessons.Query().AsNoTracking().CountAsync(l => ids.Contains(l.Id) + && l.CertificateLevelId == level.Id && !l.IsDeleted && l.Status == ContentStatus.Published + && !l.LanguageSkill.IsDeleted, ct); + return count == ids.Length; + } + + public async Task> PrepareAsync( + int cohortId, int sessionId, IReadOnlyList lessonIds, CancellationToken ct = default) + { + var actor = claims.GetUserClaim(); + if (actor.Role != Role.Mentor) return ApiResponse.Forbidden(); + if (lessonIds.Count is < 1 or > MaxLessons || lessonIds.Any(id => id <= 0) + || lessonIds.Distinct().Count() != lessonIds.Count) + return ApiResponse.Fail( + $"Chọn từ 1 đến {MaxLessons} bài học khác nhau.", HttpStatusCode.BadRequest); + + ApiResponse? failure = null; + await uow.ExecuteInTransactionAsync(async token => + { + // The class lock serializes edits and the meeting start transition. + await uow.StudyCourses.LockCohortAsync(cohortId, token); + var cohort = await uow.StudyCohorts.Query().AsNoTracking() + .Where(c => c.Id == cohortId) + .Select(c => new { c.MentorId, c.Level, c.Status, + Session = c.Sessions.Where(s => s.Id == sessionId) + .Select(s => new { s.Status, s.ActualStartedAtUtc, + MentorId = s.Availability.MentorId, s.Availability.IsDeleted, + s.Availability.IsApproved, s.Availability.RejectedAt }).FirstOrDefault() }) + .FirstOrDefaultAsync(token); + if (cohort?.Session is null) + { + failure = ApiResponse.NotFound("Không tìm thấy buổi học trong lớp."); + return; + } + if (cohort.MentorId != actor.Id || cohort.Session.MentorId != actor.Id) + { + failure = ApiResponse.Forbidden("Bạn không phụ trách buổi học này."); + return; + } + if (cohort.Status is "Draft" or "Cancelled" or "Completed" + || cohort.Session.Status is "Cancelled" or "Rescheduled" or "Completed" + || cohort.Session.ActualStartedAtUtc.HasValue || cohort.Session.IsDeleted + || !cohort.Session.IsApproved || cohort.Session.RejectedAt.HasValue) + { + failure = ApiResponse.Conflict("Buổi học đã bắt đầu hoặc không còn hợp lệ để sửa bài."); + return; + } + var levels = await uow.CertificateLevels.GetLearnerVisibleJlptLevelsAsync(token); + var level = levels.FirstOrDefault(x => string.Equals(x.Code, cohort.Level, StringComparison.OrdinalIgnoreCase)); + if (level is null) + { + failure = ApiResponse.Conflict("Level của lớp chưa khớp với chương trình JLPT."); + return; + } + var allowed = await uow.Lessons.Query().AsNoTracking().Where(l => + lessonIds.Contains(l.Id) && l.CertificateLevelId == level.Id && !l.IsDeleted + && l.Status == ContentStatus.Published && !l.LanguageSkill.IsDeleted) + .Select(l => l.Id).ToListAsync(token); + if (allowed.Count != lessonIds.Count) + { + failure = ApiResponse.Fail( + "Có bài học không thuộc level của lớp hoặc chưa được xuất bản.", HttpStatusCode.BadRequest); + return; + } + var detail = string.Join(',', lessonIds); + var existing = await LatestPlanAsync(cohortId, sessionId, token); + if (existing?.ActorId == actor.Id && string.Equals(existing.Detail, detail, StringComparison.Ordinal)) return; + var course = await uow.StudyCourses.Query() + .Where(c => c.CohortId == cohortId && (c.PaymentStatus == "Paid" || c.PaymentStatus == "PartiallyRefunded") + && (c.Status == "Active" || c.Status == "Ready")) + .OrderBy(c => c.Id).FirstOrDefaultAsync(token); + if (course is null) + { + failure = ApiResponse.Conflict("Lớp cần có học viên đã ghi danh để lưu bài học."); + return; + } + // Append-only course audit is existing persistent storage; no entity/schema change. + course.Audit.Add(new CourseAuditEntry { CourseId = course.Id, ActorId = actor.Id, + Action = PlanAction(sessionId), Detail = detail, At = DateTime.UtcNow }); + await uow.SaveChangesAsync(token); + }, ct); + return failure ?? await GetAsync(cohortId, sessionId, ct); + } + + public async Task> GetAsync( + int cohortId, int sessionId, CancellationToken ct = default) + { + var actor = claims.GetUserClaim(); + var cohort = await uow.StudyCohorts.Query().AsNoTracking() + .Where(x => x.Id == cohortId) + .Select(x => new + { + x.Id, + x.Name, + x.Level, + x.MentorId, + x.Status, + Session = x.Sessions.Where(s => s.Id == sessionId) + .Select(s => new { s.Id, s.Number, s.Status, s.ActualStartedAtUtc, + MentorId = s.Availability.MentorId }) + .FirstOrDefault() + }) + .FirstOrDefaultAsync(ct); + + if (cohort is null || cohort.Session is null) + return ApiResponse.NotFound("Không tìm thấy buổi học trong lớp."); + + if (actor.Role == Role.Mentor && cohort.Session.MentorId != actor.Id) + return ApiResponse.Forbidden("Bạn không phải Giáo viên của lớp này."); + + if (actor.Role == Role.Learner) + { + var isEnrolled = await uow.StudyCourses.Query().AsNoTracking().AnyAsync(c => + c.CohortId == cohortId + && c.LearnerId == actor.Id + && (c.PaymentStatus == "Paid" || c.PaymentStatus == "PartiallyRefunded") + && (c.Status == "Active" || c.Status == "Ready" || c.Status == "Completed"), ct); + if (!isEnrolled) + return ApiResponse.Forbidden("Bạn chưa ghi danh lớp này."); + } + else if (actor.Role is not (Role.Admin or Role.Mentor)) + { + return ApiResponse.Forbidden(); + } + + if (cohort.Session.Number < 1) + return ApiResponse.Conflict("Số thứ tự buổi học không hợp lệ."); + + if (cohort.Status is "Draft" or "Cancelled" + || cohort.Session.Status is "Cancelled" or "Rescheduled") + return ApiResponse.Conflict("Buổi học không còn hợp lệ."); + + var levels = await uow.CertificateLevels.GetLearnerVisibleJlptLevelsAsync(ct); + var level = levels.FirstOrDefault(x => string.Equals(x.Code, cohort.Level, StringComparison.OrdinalIgnoreCase)); + if (level is null) + return ApiResponse.Conflict("Level của lớp chưa khớp với chương trình JLPT."); + + var visible = uow.Lessons.Query().AsNoTracking().Where(l => + l.CertificateLevelId == level.Id && !l.IsDeleted && l.Status == ContentStatus.Published + && !l.CertificateLevel.IsDeleted && !l.CertificateLevel.CertificateType.IsDeleted + && l.CertificateLevel.CertificateType.IsActive && l.CertificateLevel.CertificateType.Name == "JLPT" + && !l.LanguageSkill.IsDeleted); + var suggested = actor.Role == Role.Mentor + ? await visible.OrderBy(l => l.SortOrder).ThenBy(l => l.Id) + .Select(l => new CohortLessonSuggestionResponse(l.Id, l.Title, l.Description, l.SortOrder, + l.EstimatedMinutes, l.LanguageSkill.Name, + l.Topic != null && !l.Topic.IsDeleted ? l.Topic.Title : null, + l.LessonKanjis!.Count(k => !k.Kanji.IsDeleted && k.Kanji.Status == ContentStatus.Published), + l.LessonVocabularies!.Count(v => !v.Vocabulary.IsDeleted && v.Vocabulary.Status == ContentStatus.Published), + l.LessonGrammars!.Count(g => !g.GrammarPattern.IsDeleted && g.GrammarPattern.Status == ContentStatus.Published))) + .ToListAsync(ct) + : []; + var lessonCount = actor.Role == Role.Mentor ? suggested.Count : await visible.CountAsync(ct); + var plan = await LatestPlanAsync(cohortId, sessionId, ct); + var selectedIds = (plan?.Detail ?? "").Split(',', StringSplitOptions.RemoveEmptyEntries) + .Select(value => int.TryParse(value, out var id) ? id : 0).Where(id => id > 0).Take(MaxLessons).ToList(); + var reveal = actor.Role != Role.Learner || cohort.Session.ActualStartedAtUtc.HasValue + || cohort.Session.Status == "Completed"; + var selected = new List(); + if (reveal && selectedIds.Count > 0) + { + var lessons = await uow.Lessons.GetLearnerVisibleByIdsAsync(selectedIds, ct); + var byId = lessons.Where(l => l.CertificateLevelId == level.Id).ToDictionary(l => l.Id); + foreach (var id in selectedIds) + { + if (!byId.TryGetValue(id, out var lesson)) continue; + selected.Add(ToMaterial(lesson)); + } + } + var canEdit = actor.Role == Role.Mentor && cohort.MentorId == actor.Id + && cohort.Session.ActualStartedAtUtc is null && cohort.Session.Status is not "Completed"; + return ApiResponse.Success(new( + cohort.Id, cohort.Name, cohort.Level, cohort.Session.Id, cohort.Session.Number, + cohort.Session.Number, lessonCount, selected.FirstOrDefault(), suggested, selected, + reveal && plan?.ActorId == cohort.MentorId && selected.Count > 0 && selected.Count == selectedIds.Count, canEdit)); + } + + private static CohortLessonLearningMaterialResponse ToMaterial(Lesson lesson) => new( + lesson.Id, + lesson.Title, + lesson.Description, + lesson.LearningObjectives, + lesson.EstimatedMinutes, + lesson.SortOrder, + lesson.LanguageSkill?.Name ?? string.Empty, + lesson.Topic is { IsDeleted: false } ? lesson.Topic.Title : null, + (lesson.LessonKanjis ?? []).Where(x => x.Kanji is not null && !x.Kanji.IsDeleted) + .OrderBy(x => x.Kanji.Character) + .Select(x => new CohortLessonKanjiResponse(x.Kanji.Id, x.Kanji.Character, x.Kanji.Meaning, + x.Kanji.SinoVietnamese, x.Kanji.OnYomi, x.Kanji.KunYomi, x.Kanji.StrokeCount)).ToList(), + (lesson.LessonVocabularies ?? []).Where(x => x.Vocabulary is not null && !x.Vocabulary.IsDeleted) + .OrderBy(x => x.Vocabulary.Word) + .Select(x => new CohortLessonVocabularyResponse(x.Vocabulary.Id, x.Vocabulary.Word, + x.Vocabulary.Reading, x.Vocabulary.Meaning, x.Vocabulary.ExampleSentence, + x.Vocabulary.ExampleSentenceMeaning)).ToList(), + (lesson.LessonGrammars ?? []).Where(x => x.GrammarPattern is not null && !x.GrammarPattern.IsDeleted) + .OrderBy(x => x.GrammarPattern.Title) + .Select(x => new CohortLessonGrammarResponse(x.GrammarPattern.Id, x.GrammarPattern.Title, + x.GrammarPattern.Structure, x.GrammarPattern.UsageNotes, + x.GrammarPattern.ExampleSentence, x.GrammarPattern.ExampleSentenceMeaning)).ToList()); +} diff --git a/RikiPath.Application/Services/ContentApprovalService.cs b/RikiPath.Application/Services/ContentApprovalService.cs index e5864981..cec0e376 100644 --- a/RikiPath.Application/Services/ContentApprovalService.cs +++ b/RikiPath.Application/Services/ContentApprovalService.cs @@ -756,6 +756,9 @@ await unitOfWork.AdminAuditLogs.AddAsync(new AdminAuditLog result.SuccessCount++; foreach (var related in cascaded) approvedWithLesson.TryAdd(related.Id, related); + // Mỗi mục đã commit riêng. Giữ entity của các Lesson trước trong + // ChangeTracker làm SaveChanges của mục sau ngày càng nặng. + unitOfWork.ClearTrackedEntities(); } catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) { diff --git a/RikiPath.Application/Services/GroupEnrollmentEntitlementContract.cs b/RikiPath.Application/Services/GroupEnrollmentEntitlementContract.cs index 894ccd3f..182392d6 100644 --- a/RikiPath.Application/Services/GroupEnrollmentEntitlementContract.cs +++ b/RikiPath.Application/Services/GroupEnrollmentEntitlementContract.cs @@ -30,7 +30,6 @@ public GroupEnrollmentEntitlementContract(IUnitOfWork uow) public GroupEnrollmentEntitlementDecision EvaluateGroupEnrollment( StudyCohort cohort, - StudyCoursePlan plan, int learnerId, string? entitlementReference) { @@ -56,7 +55,6 @@ public GroupEnrollmentEntitlementDecision EvaluateGroupEnrollment( && x.LearnerId == learnerId && x.Status == "Active" && (x.ExpiresAtUtc == null || x.ExpiresAtUtc > now) - && (x.PlanId == null || x.PlanId == plan.Id) && x.SourceType != "ConsultationCredit" && x.SourceType != "Credit1on1" && x.SourceType != "OneOnOneCredit") diff --git a/RikiPath.Application/Services/MentorAvailabilityReviewService.cs b/RikiPath.Application/Services/MentorAvailabilityReviewService.cs index 1c4dff77..382b63f2 100644 --- a/RikiPath.Application/Services/MentorAvailabilityReviewService.cs +++ b/RikiPath.Application/Services/MentorAvailabilityReviewService.cs @@ -117,6 +117,8 @@ public async Task> ReviewAsync(int id, b var seed = await unitOfWork.MentorAvailabilities.Query().AsNoTracking().FirstOrDefaultAsync(x => x.Id == id && !x.IsDeleted, cancellationToken); if (seed is null) return ApiResponse.Fail("Không tìm thấy lịch dạy của Giáo viên.", HttpStatusCode.NotFound); + if (await unitOfWork.StudyCohorts.AnyAsync(c => c.Sessions.Any(s => s.AvailabilityId == id), cancellationToken)) + return ApiResponse.Fail("Lịch lớp do quy trình phân công mentor quản lý.", HttpStatusCode.Conflict); ApiResponse? errorResponse = null; MentorAvailabilityResponse? mapped = null; @@ -692,6 +694,8 @@ public async Task> DeleteAvailabilityAsync(int id, Cancellatio return ApiResponse.Fail("Bạn không có quyền xóa khung giờ này.", HttpStatusCode.Forbidden); if (slot.IsApproved || slot.BookedCount > 0 || slot.RejectedAt != null || slot.StartTime <= DateTime.UtcNow) return ApiResponse.Fail("Lịch đã duyệt, đã xử lý hoặc đã bắt đầu không thể xóa trực tiếp.", HttpStatusCode.Conflict); + if (await unitOfWork.StudyCohorts.AnyAsync(c => c.Sessions.Any(s => s.AvailabilityId == id), cancellationToken)) + return ApiResponse.Fail("Lịch thuộc lớp nhóm; hãy phản hồi lời mời hoặc gửi yêu cầu đổi lịch.", HttpStatusCode.Conflict); slot.IsDeleted = true; await unitOfWork.SaveChangesAsync(cancellationToken); @@ -785,6 +789,8 @@ await unitOfWork.ExecuteInTransactionAsync(async token => .ToListAsync(token); if (slots.Count != distinctIds.Count) { error = ApiResponse.Fail("Có khung giờ không tồn tại.", HttpStatusCode.NotFound); return; } + if (await unitOfWork.StudyCohorts.AnyAsync(c => c.Sessions.Any(s => distinctIds.Contains(s.AvailabilityId)), token)) + { error = ApiResponse.Fail("Lịch lớp do quy trình phân công mentor quản lý.", HttpStatusCode.Conflict); return; } if (slots.Any(x => x.CancelRequestedAt is null)) { error = ApiResponse.Fail("Có khung giờ chưa có yêu cầu hủy.", HttpStatusCode.Conflict); return; } @@ -844,6 +850,7 @@ public async Task>> GetPendingAvail var slots = await unitOfWork.MentorAvailabilities.Query() .Include(x => x.Mentor) .Where(x => !x.IsDeleted && !x.IsApproved && x.RejectedAt == null && x.StartTime > DateTime.UtcNow) + .Where(x => !unitOfWork.StudyCohorts.Query().Any(c => c.Sessions.Any(s => s.AvailabilityId == x.Id))) .OrderBy(x => x.MentorId).ThenBy(x => x.StartTime) .ToListAsync(cancellationToken); return ApiResponse>.Success(slots diff --git a/RikiPath.Application/Services/MentorDiscoveryService.cs b/RikiPath.Application/Services/MentorDiscoveryService.cs index f892b9cc..24adea68 100644 --- a/RikiPath.Application/Services/MentorDiscoveryService.cs +++ b/RikiPath.Application/Services/MentorDiscoveryService.cs @@ -303,15 +303,13 @@ private async Task> LoadRecruiting var now = DateTime.UtcNow; var rows = await unitOfWork.StudyCohorts.Query().AsNoTracking() - .Include(x => x.Plan).ThenInclude(x => x.CertificateLevel) .Include(x => x.GroupPolicy) .Include(x => x.Sessions).ThenInclude(s => s.Availability).ThenInclude(a => a.GroupPolicy) .Include(x => x.Enrollments) .AsSplitQuery() .Where(x => mentorIds.Contains(x.MentorId) && x.Status == "Published" - && x.StartsAt > now - && x.Plan.IsPublished) + && x.StartsAt > now) .ToListAsync(ct); foreach (var group in rows.GroupBy(c => c.MentorId)) @@ -360,7 +358,7 @@ private async Task> LoadRecruiting totalRecruiting++; if (isOpenForEnroll) openRecruiting++; - var levelCode = cohort.Plan?.CertificateLevel?.Code?.Trim().ToUpperInvariant(); + var levelCode = cohort.Level.Trim().ToUpperInvariant(); var levelOk = string.IsNullOrEmpty(normalizedTeachingLevel) || string.Equals(levelCode, normalizedTeachingLevel, StringComparison.OrdinalIgnoreCase); if (levelOk && !string.IsNullOrEmpty(normalizedTeachingLevel)) @@ -480,7 +478,7 @@ void AddActive(int mentorId, string? rawCode) .Select(c => new { c.MentorId, - LevelCode = c.Plan != null && c.Plan.CertificateLevel != null ? c.Plan.CertificateLevel.Code : null, + LevelCode = c.Level, }) .Distinct() .ToListAsync(ct); diff --git a/RikiPath.Application/Services/MentorLearnerSkillProfileService.cs b/RikiPath.Application/Services/MentorLearnerSkillProfileService.cs index 4076befb..6212c1b1 100644 --- a/RikiPath.Application/Services/MentorLearnerSkillProfileService.cs +++ b/RikiPath.Application/Services/MentorLearnerSkillProfileService.cs @@ -121,7 +121,6 @@ public async Task> GetSkillProfil if (cohortId.HasValue) { cohort = await uow.StudyCohorts.Query().AsNoTracking() - .Include(x => x.Plan).ThenInclude(p => p.CertificateLevel) .Include(x => x.GroupPolicy) .Include(x => x.Enrollments) .Include(x => x.Sessions).ThenInclude(s => s.Availability).ThenInclude(a => a.GroupPolicy) @@ -214,8 +213,11 @@ public async Task> GetSkillProfil } // 2. Cohort lifecycle & baseline cutoff (baseline preserved once class starts). - int? targetLevelId = cohort?.Plan?.CertificateLevelId ?? learnerEnrollment?.CertificateLevelId; - string? targetLevelCode = cohort?.Plan?.CertificateLevel?.Code ?? learnerEnrollment?.CertificateLevel?.Code; + int? targetLevelId = cohort is null + ? learnerEnrollment?.CertificateLevelId + : await uow.CertificateLevels.Query().AsNoTracking().Where(level => level.Code == cohort.Level) + .Select(level => (int?)level.Id).FirstOrDefaultAsync(cancellationToken); + string? targetLevelCode = cohort?.Level ?? learnerEnrollment?.CertificateLevel?.Code; var hasClassStarted = false; var baselineCutoffUtc = nowUtc; var totalScheduledSessionsCount = 0; diff --git a/RikiPath.Application/Services/MentorTeachingConflictService.cs b/RikiPath.Application/Services/MentorTeachingConflictService.cs index b96e1e37..8291955c 100644 --- a/RikiPath.Application/Services/MentorTeachingConflictService.cs +++ b/RikiPath.Application/Services/MentorTeachingConflictService.cs @@ -143,7 +143,7 @@ private async Task> LoadCommitmentsAsync(int mentorId, DateTime CohortId = g.Id, g.Name, g.Status, - JlptLevel = g.Plan.CertificateLevel != null ? g.Plan.CertificateLevel.Code : null, + JlptLevel = g.Level, ProposalId = g.SourceProposalId, s.Availability.StartTime, s.Availability.EndTime, diff --git a/RikiPath.Application/Services/MentorTeachingProposalService.cs b/RikiPath.Application/Services/MentorTeachingProposalService.cs index e3da1342..aa2f849b 100644 --- a/RikiPath.Application/Services/MentorTeachingProposalService.cs +++ b/RikiPath.Application/Services/MentorTeachingProposalService.cs @@ -2764,7 +2764,7 @@ private async Task CreateCohortForOpenEnrollmentAsync( var cohort = new StudyCohort { - PlanId = plan.Id, + Level = levelCode, Name = cohortName, MentorId = proposal.MentorId, StartsAt = orderedSlots[0].StartTime, @@ -3342,9 +3342,8 @@ private async Task ComputeMentorWorkloadAsync( int mentorId, DateTime nowUtc, CancellationToken ct) { var activeCohorts = await unitOfWork.StudyCohorts.Query().AsNoTracking() - .Include(c => c.Plan) .Where(c => c.MentorId == mentorId && (c.Status == "Published" || c.Status == "Draft") && c.EndsAt > nowUtc) - .Select(c => new { c.Id, c.SourceProposalId, c.Plan.SessionsPerWeek }) + .Select(c => new { c.Id, c.SourceProposalId, SessionsPerWeek = c.Sessions.Select(s => s.Availability.StartTime.DayOfWeek).Distinct().Count() }) .ToListAsync(ct); var linkedProposalIds = activeCohorts diff --git a/RikiPath.Application/Services/MockTestService.cs b/RikiPath.Application/Services/MockTestService.cs index 43facf2e..b1ca1615 100644 --- a/RikiPath.Application/Services/MockTestService.cs +++ b/RikiPath.Application/Services/MockTestService.cs @@ -826,7 +826,7 @@ public async Task> GetAttemptSnapshotAsync(int if (attempt.IsCompleted) return ApiResponse.Fail("Lượt làm bài đã được nộp.", HttpStatusCode.Conflict, errorCode: "MOCK_TEST_COMPLETED"); - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, cancellationToken); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, cancellationToken); var mockTest = answers.FirstOrDefault()?.MockQuestion?.MockTestSection?.MockTest; var resolvedExamKind = ResolveEffectiveExamKind( frozen?.ExamKind, @@ -973,7 +973,7 @@ await unitOfWork.ExecuteInTransactionAsync(async transactionCancellationToken => return; } - var snapshotAnswers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync( + var snapshotAnswers = await LoadAttemptAnswersWithLegacyProjectionAsync( attemptId, transactionCancellationToken); if (snapshotAnswers.Count == 0) { @@ -1317,7 +1317,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => response = ApiResponse.Fail("Lượt làm bài đã kết thúc.", HttpStatusCode.Conflict, errorCode: "MOCK_TEST_ABANDONED"); return; } - var snapshots = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, ct); + var snapshots = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, ct); var mockTest = snapshots.FirstOrDefault()?.MockQuestion.MockTestSection.MockTest; var timeLimitMinutes = mockTest?.TimeLimitMinutes ?? 0; var isPractice = (mockTest is not null && IsPracticeExamKind(mockTest.ExamKind)) || IsPracticeExamKind(existingSnap?.ExamKind); @@ -1433,7 +1433,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => var frozenRaw = TryReadMockSnapshotSafe(attempt); if (IsAttemptAbandoned(frozenRaw)) continue; - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attempt.Id, cancellationToken); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(attempt.Id, cancellationToken); if (answers.Count == 0) continue; var frozenQuestions = ReadFrozenQuestions(attempt, answers); var frozen = frozenQuestions is null ? frozenRaw : ReadMockSnapshot(attempt); @@ -1562,7 +1562,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => alreadyCompleted = true; return; } - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, ct); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, ct); if (answers.Count == 0 || answers.Select(a => a.MockQuestion.MockTestSection.MockTestId).Distinct().Count() != 1) { response = ApiResponse.Fail("Dữ liệu câu hỏi của lượt thi không hợp lệ.", HttpStatusCode.Conflict); @@ -1678,7 +1678,7 @@ public async Task> GetAttemptResultAsync(int attemptId, cancellationToken); // Đồng bộ với SubmitAttemptAsync: trả luôn danh sách câu sai. - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync( + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync( attemptId, cancellationToken); var snap = TryReadMockSnapshotSafe(attempt); var mockTest = answers.FirstOrDefault()?.MockQuestion?.MockTestSection?.MockTest @@ -1765,25 +1765,83 @@ public async Task> GetAttemptResultAsync(int } } + private static IQueryable ProjectLearnerTestGraph(IQueryable query) => + query.Select(test => new MockTest + { + Id = test.Id, + Title = test.Title, + Description = test.Description, + TimeLimitMinutes = test.TimeLimitMinutes, + CertificateLevelId = test.CertificateLevelId, + ExamKind = test.ExamKind, + IsArchivedVersion = test.IsArchivedVersion, + IsManagedWorkflow = test.IsManagedWorkflow, + IsDeleted = test.IsDeleted, + CreatedDate = test.CreatedDate, + ModifiedDate = test.ModifiedDate, + CertificateLevel = new CertificateLevel + { + Id = test.CertificateLevel.Id, + Code = test.CertificateLevel.Code, + IsDeleted = test.CertificateLevel.IsDeleted, + }, + Sections = test.Sections! + .Where(section => !section.IsDeleted) + .Select(section => new MockTestSection + { + Id = section.Id, + Title = section.Title, + SortOrder = section.SortOrder, + LanguageSkillId = section.LanguageSkillId, + IsDeleted = section.IsDeleted, + LanguageSkill = new LanguageSkill + { + Id = section.LanguageSkill.Id, + Name = section.LanguageSkill.Name, + }, + Questions = section.Questions! + .Where(question => !question.IsDeleted) + .Select(question => new MockQuestion + { + Id = question.Id, + QuestionText = question.QuestionText, + QuestionType = question.QuestionType, + InteractionDataJson = question.InteractionDataJson, + AnswerKeyJson = question.AnswerKeyJson, + AudioUrl = question.AudioUrl, + ImageUrl = question.ImageUrl, + SortOrder = question.SortOrder, + IsDeleted = question.IsDeleted, + Options = question.Options! + .Where(option => !option.IsDeleted) + .Select(option => new MockQuestionOption + { + Id = option.Id, + OptionText = option.OptionText, + ImageUrl = option.ImageUrl, + IsCorrect = option.IsCorrect, + SortOrder = option.SortOrder, + IsDeleted = option.IsDeleted, + }) + .ToList(), + }) + .ToList(), + }) + .ToList(), + }); + public async Task>> GetTestsByLevelAsync( int certificationLevelId, CancellationToken cancellationToken = default) { try { - var tests = await unitOfWork.MockTests.Query().AsNoTracking() + var query = unitOfWork.MockTests.Query().AsNoTracking() .Where(test => !test.IsDeleted && test.CertificateLevelId == certificationLevelId && test.ExamKind == ExamKind.FullMockTest - && !test.IsArchivedVersion) - .Include(test => test.CertificateLevel) - .Include(test => test.Sections.Where(section => !section.IsDeleted)) - .ThenInclude(section => section.LanguageSkill) - .Include(test => test.Sections.Where(section => !section.IsDeleted)) - .ThenInclude(section => section.Questions.Where(question => !question.IsDeleted)) - .ThenInclude(question => question.Options.Where(option => !option.IsDeleted)) - .Include(test => test.Sections.Where(section => !section.IsDeleted)) - .ThenInclude(section => section.Questions.Where(question => !question.IsDeleted)) - .ThenInclude(question => question.Passage) - .AsSplitQuery().ToListAsync(cancellationToken); + && !test.IsArchivedVersion); + var tests = await ProjectLearnerTestGraph(query) + .AsSplitQuery() + .ToListAsync(cancellationToken); var approvedIds = (await ContentAuthoring.MockContentReviewState.ApprovedExamIds(unitOfWork) .ToListAsync(cancellationToken)).ToHashSet(); @@ -1829,11 +1887,7 @@ public async Task>> GetPracticeSetsAsync( query = query.Where(t => t.Title.ToLower().Contains(kw) || (t.Description != null && t.Description.ToLower().Contains(kw))); } - var tests = await query - .Include(t => t.CertificateLevel) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.LanguageSkill) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.Questions!.Where(q => !q.IsDeleted)).ThenInclude(q => q.Options!.Where(o => !o.IsDeleted)) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.Questions!.Where(q => !q.IsDeleted)).ThenInclude(q => q.Passage) + var tests = await ProjectLearnerTestGraph(query) .AsSplitQuery() .OrderByDescending(t => t.ModifiedDate ?? t.CreatedDate) .ToListAsync(cancellationToken); @@ -1881,11 +1935,7 @@ public async Task>> GetFullMockTestsAsync( query = query.Where(t => t.Title.ToLower().Contains(kw) || (t.Description != null && t.Description.ToLower().Contains(kw))); } - var tests = await query - .Include(t => t.CertificateLevel) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.LanguageSkill) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.Questions!.Where(q => !q.IsDeleted)).ThenInclude(q => q.Options!.Where(o => !o.IsDeleted)) - .Include(t => t.Sections!.Where(s => !s.IsDeleted)).ThenInclude(s => s.Questions!.Where(q => !q.IsDeleted)).ThenInclude(q => q.Passage) + var tests = await ProjectLearnerTestGraph(query) .AsSplitQuery() .OrderBy(t => t.CertificateLevelId).ThenByDescending(t => t.CreatedDate) .ToListAsync(cancellationToken); @@ -2680,7 +2730,7 @@ public async Task> GetDetailedResultA return ApiResponse.Fail( "Lượt làm bài này chưa được nộp/chấm điểm.", HttpStatusCode.BadRequest); - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync( + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync( attemptId, cancellationToken); var frozenQuestionsById = ReadFrozenQuestions(attempt, answers); @@ -2926,7 +2976,7 @@ public async Task> GetStatusAsync( var active = attempts.FirstOrDefault(a => !a.IsCompleted); if (active is not null) { - var activeAnswers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(active.Id, cancellationToken); + var activeAnswers = await LoadAttemptAnswersWithLegacyProjectionAsync(active.Id, cancellationToken); if (activeAnswers.Count > 0 && !IsExpired(active, activeAnswers)) { status.HasActiveAttempt = true; @@ -2939,7 +2989,7 @@ public async Task> GetStatusAsync( var completed = attempts.FirstOrDefault(a => a.IsCompleted); if (completed is not null) { - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(completed.Id, cancellationToken); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(completed.Id, cancellationToken); if (answers.Count > 0) { var latest = await BuildPlacementResultAsync(completed, answers, cancellationToken); @@ -3101,7 +3151,7 @@ public async Task> SkipPlacementAsync( if (active is null) return ApiResponse.Success(null); - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(active.Id, cancellationToken); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(active.Id, cancellationToken); // Hết giờ thì không cho resume; FE cho học viên làm lại. if (answers.Count == 0 || IsExpired(active, answers)) return ApiResponse.Success(null); @@ -3197,7 +3247,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => if (existing is not null) { - var existingAnswers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(existing.Id, ct); + var existingAnswers = await LoadAttemptAnswersWithLegacyProjectionAsync(existing.Id, ct); if (!request.RestartExisting && existingAnswers.Count > 0 && existingAnswers.All(answer => answer.MockQuestion.MockTestSection.MockTestId == request.MockTestId) && !IsExpired(existing, existingAnswers)) @@ -3235,7 +3285,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => await unitOfWork.SaveChangesAsync(ct); // Load lại để có đủ navigation (Section/Test/Options) dựng snapshot. - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attempt.Id, ct); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(attempt.Id, ct); response = ApiResponse.Created( await BuildSnapshotAsync(attempt, answers, isResumed: false, ct)); }, cancellationToken); @@ -3259,7 +3309,7 @@ public async Task> SavePlacementAnswerAs if (attempt is null) return ApiResponse.Fail(error!, code); - var snapshots = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, cancellationToken); + var snapshots = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, cancellationToken); if (snapshots.Count == 0) return ApiResponse.Fail( "Lượt làm bài không có snapshot hợp lệ.", HttpStatusCode.Conflict); @@ -3307,7 +3357,7 @@ public async Task> SavePlacementAnswe if (attempt is null) return ApiResponse.Fail(error!, code); - var snapshots = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, cancellationToken); + var snapshots = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, cancellationToken); if (snapshots.Count == 0 || IsExpired(attempt, snapshots)) return ApiResponse.Fail( "Lượt làm bài không hợp lệ hoặc đã hết thời gian.", HttpStatusCode.BadRequest); @@ -3368,7 +3418,7 @@ await unitOfWork.ExecuteInTransactionAsync(async ct => return; } - var snapshots = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, ct); + var snapshots = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, ct); if (snapshots.Count == 0) { response = ApiResponse.Fail( @@ -3451,7 +3501,7 @@ public async Task> GetPlacementTestResu return ApiResponse.Fail( "Lượt làm bài này chưa được nộp/chấm điểm.", HttpStatusCode.BadRequest); - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, cancellationToken); + var answers = await LoadAttemptAnswersWithLegacyProjectionAsync(attemptId, cancellationToken); if (answers.Count == 0) return ApiResponse.Fail( "Lượt làm bài không có dữ liệu hợp lệ.", HttpStatusCode.Conflict); @@ -3503,6 +3553,180 @@ public async Task> GetPlacementTestResu return (attempt, HttpStatusCode.OK, null); } + /// + /// Loads attempt answers without materializing legacy shadow columns from MockQuestions or MockTests. + /// Those columns are not present in every deployed schema, but the learner flows below only need + /// question content, options, section, test and level data. + /// + private async Task> LoadAttemptAnswersWithLegacyProjectionAsync( + int attemptId, CancellationToken ct) + { + var answers = await unitOfWork.MockTestAnswers.Query() + .Where(answer => answer.MockTestAttemptId == attemptId) + .OrderBy(answer => answer.MockQuestion.MockTestSection!.SortOrder) + .ThenBy(answer => answer.MockQuestion.SortOrder) + .ToListAsync(ct); + + if (answers.Count == 0) + return answers; + + var questionIds = answers.Select(answer => answer.MockQuestionId).Distinct().ToArray(); + var questionRows = await unitOfWork.MockQuestions.Query() + .Where(question => questionIds.Contains(question.Id)) + .Select(question => new AttemptAnswerQuestionProjection + { + QuestionId = question.Id, + QuestionText = question.QuestionText, + QuestionType = question.QuestionType, + InteractionDataJson = question.InteractionDataJson, + AnswerKeyJson = question.AnswerKeyJson, + AudioUrl = question.AudioUrl, + AudioTranscript = question.AudioTranscript, + ImageUrl = question.ImageUrl, + Explanation = question.Explanation, + SortOrder = question.SortOrder, + GroupSortOrder = question.GroupSortOrder, + IsDeleted = question.IsDeleted, + SectionId = question.MockTestSection!.Id, + SectionTitle = question.MockTestSection.Title, + SectionSortOrder = question.MockTestSection.SortOrder, + SectionIsDeleted = question.MockTestSection.IsDeleted, + LanguageSkillId = question.MockTestSection.LanguageSkillId, + LanguageSkillName = question.MockTestSection.LanguageSkill.Name, + LanguageSkillCode = question.MockTestSection.LanguageSkill.Code, + LanguageSkillIsDeleted = question.MockTestSection.LanguageSkill.IsDeleted, + MockTestId = question.MockTestSection.MockTestId, + MockTestTitle = question.MockTestSection.MockTest.Title, + MockTestTimeLimitMinutes = question.MockTestSection.MockTest.TimeLimitMinutes, + MockTestExamKind = question.MockTestSection.MockTest.ExamKind, + MockTestIsDeleted = question.MockTestSection.MockTest.IsDeleted, + MockTestIsArchivedVersion = question.MockTestSection.MockTest.IsArchivedVersion, + MockTestIsManagedWorkflow = question.MockTestSection.MockTest.IsManagedWorkflow, + CertificateLevelId = question.MockTestSection.MockTest.CertificateLevelId, + CertificateLevelCode = question.MockTestSection.MockTest.CertificateLevel.Code, + CertificateLevelIsDeleted = question.MockTestSection.MockTest.CertificateLevel.IsDeleted, + Options = question.Options! + .Select(option => new AttemptAnswerOptionProjection + { + Id = option.Id, + OptionText = option.OptionText, + ImageUrl = option.ImageUrl, + Explanation = option.Explanation, + IsCorrect = option.IsCorrect, + SortOrder = option.SortOrder, + IsDeleted = option.IsDeleted, + }) + .ToList(), + }) + .AsSplitQuery() + .ToListAsync(ct); + + var levels = new Dictionary(); + var skills = new Dictionary(); + var tests = new Dictionary(); + var sections = new Dictionary(); + var questions = new Dictionary(); + + foreach (var row in questionRows) + { + if (questions.ContainsKey(row.QuestionId)) + continue; + + if (!levels.TryGetValue(row.CertificateLevelId, out var level)) + { + level = new CertificateLevel + { + Id = row.CertificateLevelId, + Code = row.CertificateLevelCode, + IsDeleted = row.CertificateLevelIsDeleted, + }; + levels.Add(level.Id, level); + } + + if (!skills.TryGetValue(row.LanguageSkillId, out var skill)) + { + skill = new LanguageSkill + { + Id = row.LanguageSkillId, + Name = row.LanguageSkillName, + Code = row.LanguageSkillCode, + IsDeleted = row.LanguageSkillIsDeleted, + }; + skills.Add(skill.Id, skill); + } + + if (!tests.TryGetValue(row.MockTestId, out var test)) + { + test = new MockTest + { + Id = row.MockTestId, + Title = row.MockTestTitle, + TimeLimitMinutes = row.MockTestTimeLimitMinutes, + ExamKind = row.MockTestExamKind, + CertificateLevelId = row.CertificateLevelId, + CertificateLevel = level, + IsDeleted = row.MockTestIsDeleted, + IsArchivedVersion = row.MockTestIsArchivedVersion, + IsManagedWorkflow = row.MockTestIsManagedWorkflow, + }; + tests.Add(test.Id, test); + } + + if (!sections.TryGetValue(row.SectionId, out var section)) + { + section = new MockTestSection + { + Id = row.SectionId, + Title = row.SectionTitle, + SortOrder = row.SectionSortOrder, + MockTestId = row.MockTestId, + LanguageSkillId = row.LanguageSkillId, + LanguageSkill = skill, + MockTest = test, + IsDeleted = row.SectionIsDeleted, + }; + sections.Add(section.Id, section); + } + + var question = new MockQuestion + { + Id = row.QuestionId, + QuestionText = row.QuestionText, + QuestionType = row.QuestionType, + InteractionDataJson = row.InteractionDataJson, + AnswerKeyJson = row.AnswerKeyJson, + AudioUrl = row.AudioUrl, + AudioTranscript = row.AudioTranscript, + ImageUrl = row.ImageUrl, + Explanation = row.Explanation, + SortOrder = row.SortOrder, + GroupSortOrder = row.GroupSortOrder, + IsDeleted = row.IsDeleted, + MockTestSectionId = row.SectionId, + MockTestSection = section, + Options = row.Options.Select(option => new MockQuestionOption + { + Id = option.Id, + OptionText = option.OptionText, + ImageUrl = option.ImageUrl, + Explanation = option.Explanation, + IsCorrect = option.IsCorrect, + SortOrder = option.SortOrder, + IsDeleted = option.IsDeleted, + }).ToList(), + }; + questions.Add(question.Id, question); + } + + foreach (var answer in answers) + { + if (answer.MockQuestion is null && questions.TryGetValue(answer.MockQuestionId, out var question)) + answer.MockQuestion = question; + } + + return answers; + } + // Tổng thời gian = tổng TimeLimitMinutes của các đề tham gia attempt; tính từ StartedAt phía server. private static int GetTimeLimitMinutes(IEnumerable answers) { @@ -3706,6 +3930,52 @@ private sealed record ProjectedSectionScoreRow( int TotalCount, double ScorePercent); + private sealed class AttemptAnswerQuestionProjection + { + public int QuestionId { get; set; } + public string QuestionText { get; set; } = string.Empty; + public string QuestionType { get; set; } = "SingleChoice"; + public string? InteractionDataJson { get; set; } + public string? AnswerKeyJson { get; set; } + public string? AudioUrl { get; set; } + public string? AudioTranscript { get; set; } + public string? ImageUrl { get; set; } + public string? Explanation { get; set; } + public int SortOrder { get; set; } + public int GroupSortOrder { get; set; } + public bool IsDeleted { get; set; } + public int SectionId { get; set; } + public string SectionTitle { get; set; } = string.Empty; + public int SectionSortOrder { get; set; } + public bool SectionIsDeleted { get; set; } + public int LanguageSkillId { get; set; } + public string LanguageSkillName { get; set; } = string.Empty; + public string? LanguageSkillCode { get; set; } + public bool LanguageSkillIsDeleted { get; set; } + public int MockTestId { get; set; } + public string MockTestTitle { get; set; } = string.Empty; + public int MockTestTimeLimitMinutes { get; set; } + public ExamKind MockTestExamKind { get; set; } + public bool MockTestIsDeleted { get; set; } + public bool MockTestIsArchivedVersion { get; set; } + public bool MockTestIsManagedWorkflow { get; set; } + public int CertificateLevelId { get; set; } + public string CertificateLevelCode { get; set; } = string.Empty; + public bool CertificateLevelIsDeleted { get; set; } + public List Options { get; set; } = []; + } + + private sealed class AttemptAnswerOptionProjection + { + public int Id { get; set; } + public string OptionText { get; set; } = string.Empty; + public string? ImageUrl { get; set; } + public string? Explanation { get; set; } + public bool IsCorrect { get; set; } + public int SortOrder { get; set; } + public bool IsDeleted { get; set; } + } + private static MockAttemptScoringSummary BuildScoringFromProjectedRows( string? examKind, string? jlptLevelCode, diff --git a/RikiPath.Application/Services/NotificationService.cs b/RikiPath.Application/Services/NotificationService.cs index 2846a85a..193ece94 100644 --- a/RikiPath.Application/Services/NotificationService.cs +++ b/RikiPath.Application/Services/NotificationService.cs @@ -373,6 +373,10 @@ public async Task CreateNotificationAsync(string title, string message, string t await hubContext.Clients.Group(userGroup).SendAsync("UnreadCountChanged", unreadCount, cancellationToken); + var actionableList = await GetResolvedActionableResponsesAsync(userId, onlyUnread: false, cancellationToken); + + await hubContext.Clients.Group(userGroup).SendAsync("ActionableCountChanged", actionableList.Count, cancellationToken); + } catch diff --git a/RikiPath.Application/Services/PracticeTestService.cs b/RikiPath.Application/Services/PracticeTestService.cs index 2740de1c..efb4d7b6 100644 --- a/RikiPath.Application/Services/PracticeTestService.cs +++ b/RikiPath.Application/Services/PracticeTestService.cs @@ -419,7 +419,7 @@ await unitOfWork.ExecuteInTransactionAsync(async transactionCancellationToken => foreach (var answer in request.Answers) ApplyPlacementSelection(questionsById[answer.QuestionId], answer); - var answerRows = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attemptId, transactionCancellationToken); + var answerRows = await LoadAttemptAnswerRowsAsync(attemptId, transactionCancellationToken); var answersByQuestionId = answerRows.ToDictionary(a => a.MockQuestionId); foreach (var answer in request.Answers) { @@ -1187,7 +1187,7 @@ await unitOfWork.ExecuteInTransactionAsync(async transactionCancellationToken => ? question.OrderingResponse is { } sequence && sequence.SequenceEqual(answerKey) : question.CorrectOptionId.HasValue && question.SelectedOptionId == question.CorrectOptionId; - var existingAnswerRows = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync( + var existingAnswerRows = await LoadAttemptAnswerRowsAsync( attemptId, transactionCancellationToken); if (existingAnswerRows.Count > 0) @@ -1204,10 +1204,11 @@ await unitOfWork.ExecuteInTransactionAsync(async transactionCancellationToken => } var sectionResults = BuildSectionResultsFromSnapshot(attemptId, snapshotDoc.Questions); - var existingSectionResults = await unitOfWork.MockTestSectionResults.GetByAttemptIdAsync( - attemptId, - transactionCancellationToken); - if (existingSectionResults.Count == 0 && sectionResults.Entities.Count > 0) + var existingSectionResultIds = await unitOfWork.MockTestSectionResults.Query() + .Where(result => !result.IsDeleted && result.MockTestAttemptId == attemptId) + .Select(result => result.Id) + .ToListAsync(transactionCancellationToken); + if (existingSectionResultIds.Count == 0 && sectionResults.Entities.Count > 0) { await unitOfWork.MockTestSectionResults.AddRangeAsync( sectionResults.Entities, @@ -2076,7 +2077,7 @@ private static ( ? Math.Max(0, (int)(submittedUtc.Value - startedUtc).TotalSeconds) : 0; - var answers = await unitOfWork.MockTestAnswers.GetByAttemptIdAsync(attempt.Id, cancellationToken); + var answers = await LoadAttemptAnswersForLegacyRecoveryAsync(attempt.Id, cancellationToken); var answersByQuestionId = answers.ToDictionary(a => a.MockQuestionId); // Tier 1: Frozen snapshot questions exist (without CompletedResult) @@ -2134,7 +2135,23 @@ private static ( } // Tier 2: Reconstruct strictly from persisted MockTestSectionResults & MockTestAnswers - var persistedSections = await unitOfWork.MockTestSectionResults.GetByAttemptIdAsync(attempt.Id, cancellationToken); + var persistedSections = await unitOfWork.MockTestSectionResults.Query() + .Where(result => !result.IsDeleted && result.MockTestAttemptId == attempt.Id) + .OrderBy(result => result.MockTestSection.SortOrder) + .Select(result => new + { + result.MockTestSectionId, + result.CorrectCount, + result.TotalCount, + result.ScorePercent, + SectionTitle = result.MockTestSection.Title, + SectionSortOrder = result.MockTestSection.SortOrder, + LanguageSkillName = result.MockTestSection.LanguageSkill.Name, + LanguageSkillCode = result.MockTestSection.LanguageSkill.Code, + CertificateLevelId = result.MockTestSection.MockTest.CertificateLevelId, + CertificateLevelCode = result.MockTestSection.MockTest.CertificateLevel.Code, + }) + .ToListAsync(cancellationToken); if (persistedSections.Count == 0 && answers.Count == 0) { return null; @@ -2159,23 +2176,22 @@ private static ( var sections = persistedSections.Count > 0 ? persistedSections - .OrderBy(r => r.MockTestSection?.SortOrder ?? int.MaxValue) + .OrderBy(r => r.SectionSortOrder) .ThenBy(r => r.MockTestSectionId) .Select(r => { - var sec = r.MockTestSection; - var lvlCode = NormalizeLevelCode(sec?.MockTest?.CertificateLevel?.Code); - var lvlId = sec?.MockTest?.CertificateLevelId ?? 0; - var skillName = sec?.LanguageSkill?.Name ?? string.Empty; + var lvlCode = NormalizeLevelCode(r.CertificateLevelCode); + var lvlId = r.CertificateLevelId; + var skillName = r.LanguageSkillName ?? string.Empty; var hasAudio = JlptSkillAssessmentPolicy.Classify(skillName) != JlptStudySkill.Listening || !audioMissingSections.Contains(r.MockTestSectionId); var pct = r.TotalCount > 0 ? Math.Round(r.CorrectCount * 100d / r.TotalCount, 2) : r.ScorePercent; return new SectionResultItem { MockTestSectionId = r.MockTestSectionId, - SectionTitle = sec?.Title ?? skillName, + SectionTitle = r.SectionTitle ?? skillName, LanguageSkillName = skillName, - LanguageSkillCode = sec?.LanguageSkill?.Code, + LanguageSkillCode = r.LanguageSkillCode, JlptLevelId = lvlId, JlptLevelName = IsSupportedLevel(lvlCode) ? lvlCode : string.Empty, HasAudioEvidence = hasAudio, @@ -2277,6 +2293,102 @@ private static ( }; } + private async Task> LoadAttemptAnswerRowsAsync( + int attemptId, + CancellationToken cancellationToken) + => await unitOfWork.MockTestAnswers.Query() + .Where(answer => answer.MockTestAttemptId == attemptId) + .ToListAsync(cancellationToken); + + /// + /// Rebuilds only the legacy recovery graph from explicit columns. The repository Include query + /// materializes shadow metadata columns that are absent in some deployed databases. + /// + private async Task> LoadAttemptAnswersForLegacyRecoveryAsync( + int attemptId, + CancellationToken cancellationToken) + { + var answers = await LoadAttemptAnswerRowsAsync(attemptId, cancellationToken); + if (answers.Count == 0) + { + return answers; + } + + var questionIds = answers.Select(answer => answer.MockQuestionId).Distinct().ToArray(); + var questionRows = await unitOfWork.MockQuestions.Query() + .Where(question => questionIds.Contains(question.Id)) + .Select(question => new + { + QuestionId = question.Id, + question.AudioUrl, + SectionId = question.MockTestSection == null ? (int?)null : question.MockTestSection.Id, + SectionTitle = question.MockTestSection == null ? null : question.MockTestSection.Title, + SectionSortOrder = question.MockTestSection == null ? (int?)null : question.MockTestSection.SortOrder, + LanguageSkillId = question.MockTestSection == null ? (int?)null : question.MockTestSection.LanguageSkillId, + LanguageSkillName = question.MockTestSection == null ? null : question.MockTestSection.LanguageSkill.Name, + LanguageSkillCode = question.MockTestSection == null ? null : question.MockTestSection.LanguageSkill.Code, + MockTestId = question.MockTestSection == null ? (int?)null : question.MockTestSection.MockTestId, + CertificateLevelId = question.MockTestSection == null + ? (int?)null + : question.MockTestSection.MockTest.CertificateLevelId, + CertificateLevelCode = question.MockTestSection == null + ? null + : question.MockTestSection.MockTest.CertificateLevel.Code, + }) + .ToListAsync(cancellationToken); + + var rowsByQuestionId = questionRows.ToDictionary(row => row.QuestionId); + foreach (var answer in answers) + { + if (!rowsByQuestionId.TryGetValue(answer.MockQuestionId, out var row)) + { + continue; + } + + MockTestSection? section = null; + if (row.SectionId.HasValue) + { + var levelId = row.CertificateLevelId ?? 0; + var test = new MockTest + { + Id = row.MockTestId ?? 0, + CertificateLevelId = levelId, + CertificateLevel = new CertificateLevel + { + Id = levelId, + Code = row.CertificateLevelCode ?? string.Empty, + }, + }; + var skillId = row.LanguageSkillId ?? 0; + section = new MockTestSection + { + Id = row.SectionId.Value, + Title = row.SectionTitle ?? string.Empty, + SortOrder = row.SectionSortOrder ?? 0, + MockTestId = row.MockTestId ?? 0, + MockTest = test, + LanguageSkillId = skillId, + LanguageSkill = new LanguageSkill + { + Id = skillId, + Name = row.LanguageSkillName ?? string.Empty, + Code = row.LanguageSkillCode ?? string.Empty, + }, + }; + } + + answer.MockQuestion = new MockQuestion + { + Id = row.QuestionId, + AudioUrl = row.AudioUrl, + MockTestSectionId = row.SectionId, + MockTestSection = section, + }; + } + + return answers; + } + private static (List Entities, List Responses, double OverallScore) BuildSectionResultsFromSnapshot( int attemptId, diff --git a/RikiPath.Application/Services/SidebarCounterNotifier.cs b/RikiPath.Application/Services/SidebarCounterNotifier.cs index 876c7b88..89652d7b 100644 --- a/RikiPath.Application/Services/SidebarCounterNotifier.cs +++ b/RikiPath.Application/Services/SidebarCounterNotifier.cs @@ -7,11 +7,12 @@ namespace RikiPath.Application.Services; /// -/// Best-effort SignalR trigger prompting affected users' frontends to refetch authoritative sidebar counters. +/// Best-effort SignalR delivery of authoritative sidebar counter snapshots. /// Never throws or aborts domain transactions. /// public sealed class SidebarCounterNotifier( IUnitOfWork unitOfWork, + ISidebarCounterService counterService, IHubContext? hubContext = null) : ISidebarCounterNotifier { public async Task NotifyUsersAsync( @@ -26,23 +27,33 @@ public async Task NotifyUsersAsync( if (targets.Count == 0) return; - var payload = new { Reason = reason, AtUtc = DateTime.UtcNow }; - foreach (var userId in targets) + try { - try - { - await hubContext.Clients - .Group($"user_{userId}") - .SendAsync("SidebarCountersChanged", payload, cancellationToken); - await hubContext.Clients - .Group($"user_{userId}") - .SendAsync("NotificationsSynced", payload, cancellationToken); - } - catch + var users = await unitOfWork.UserAccounts.Query().AsNoTracking() + .Where(u => targets.Contains(u.Id) && !u.IsDeleted) + .Select(u => new { u.Id, u.Role }) + .ToListAsync(cancellationToken); + foreach (var user in users) { - // Best-effort SignalR signal; fallback polling & focus refetch still maintain consistency. + try + { + var result = await counterService.GetForUserAsync(user.Id, user.Role, cancellationToken); + if (!result.IsSuccess || result.Result is null) + continue; + await hubContext.Clients + .Group($"user_{user.Id}") + .SendAsync("SidebarCountersChanged", new { Reason = reason, Snapshot = result.Result }, cancellationToken); + } + catch + { + // Other users can still receive their snapshot. + } } } + catch + { + // A failed best-effort notification cannot abort the business operation. + } } public async Task NotifyAdminsAsync(string reason, CancellationToken cancellationToken = default) @@ -58,7 +69,17 @@ public async Task NotifyAdminsAsync(string reason, CancellationToken cancellatio .Select(u => u.Id) .ToListAsync(cancellationToken); - await NotifyUsersAsync(adminIds, reason, cancellationToken); + if (adminIds.Count == 0) + return; + + var result = await counterService.GetForUserAsync(adminIds[0], Role.Admin, cancellationToken); + if (!result.IsSuccess || result.Result is null) + return; + + var payload = new { Reason = reason, Snapshot = result.Result }; + foreach (var adminId in adminIds) + await hubContext.Clients.Group($"user_{adminId}") + .SendAsync("SidebarCountersChanged", payload, cancellationToken); } catch { diff --git a/RikiPath.Application/Services/SidebarCounterService.cs b/RikiPath.Application/Services/SidebarCounterService.cs index 0c2a829d..ef11504a 100644 --- a/RikiPath.Application/Services/SidebarCounterService.cs +++ b/RikiPath.Application/Services/SidebarCounterService.cs @@ -18,37 +18,57 @@ public sealed class SidebarCounterService( IUnitOfWork unitOfWork, IClaimService claimService) : ISidebarCounterService { + private static long lastServerVersionMs; + + private static long NextServerVersionMs() + { + while (true) + { + var previous = Interlocked.Read(ref lastServerVersionMs); + var nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var next = Math.Max(nowMs, previous + 1); + if (Interlocked.CompareExchange(ref lastServerVersionMs, next, previous) == previous) + return next; + } + } + public async Task> GetMyCountersAsync( CancellationToken cancellationToken = default) { var actor = claimService.GetUserClaim(); - if (actor.Id <= 0) + return await GetForUserAsync(actor.Id, actor.Role, cancellationToken); + } + + public async Task> GetForUserAsync( + int userId, Role role, CancellationToken cancellationToken = default) + { + if (userId <= 0) return ApiResponse.Fail("Phiên đăng nhập không hợp lệ.", HttpStatusCode.Unauthorized); var userExists = await unitOfWork.UserAccounts.Query() .AsNoTracking() - .AnyAsync(u => u.Id == actor.Id && !u.IsDeleted && u.Role == actor.Role, cancellationToken); + .AnyAsync(u => u.Id == userId && !u.IsDeleted && u.Role == role, cancellationToken); if (!userExists) return ApiResponse.Fail("Tài khoản không còn hiệu lực hoặc vai trò đã thay đổi.", HttpStatusCode.Unauthorized); var utcNow = DateTime.UtcNow; var response = new SidebarCountersResponse { - Role = actor.Role.ToString(), + Role = role.ToString(), UpdatedAtUtc = utcNow, - ServerVersionMs = new DateTimeOffset(utcNow).ToUnixTimeMilliseconds(), + ServerVersionMs = NextServerVersionMs(), Counters = [], }; // Execute queries sequentially: IUnitOfWork repositories share one scoped DbContext. - switch (actor.Role) + switch (role) { case Role.Learner: - await PopulateLearnerCountersAsync(actor.Id, utcNow, response, cancellationToken); + await PopulateLearnerCountersAsync(userId, utcNow, response, cancellationToken); break; case Role.Mentor: - await PopulateMentorCountersAsync(actor.Id, utcNow, response, cancellationToken); + await PopulateMentorCountersAsync(userId, utcNow, response, cancellationToken); break; case Role.Admin: @@ -56,7 +76,7 @@ public async Task> GetMyCountersAsync( break; case Role.ContentAuthor: - await PopulateContentAuthorCountersAsync(actor.Id, response, cancellationToken); + await PopulateContentAuthorCountersAsync(userId, response, cancellationToken); break; default: @@ -235,27 +255,20 @@ private async Task PopulateMentorCountersAsync( Kind = SidebarCounterKind.ActionRequired, }); - var linkedCohortProposalIds = await unitOfWork.StudyCohorts.Query() + // The proposal workflow is read-only; new teaching requests are invitations. + var pendingCohortInvitations = await unitOfWork.StudyCohortMentorInvitations.Query() .AsNoTracking() - .Where(c => c.MentorId == mentorId && c.SourceProposalId != null) - .Select(c => c.SourceProposalId!.Value) - .Distinct() - .ToListAsync(ct); - - // Tổng số đề xuất cần Giáo viên xử lý: Cần bổ sung hoặc Đã duyệt nhưng chưa mở tuyển sinh. - var proposalsActionRequired = await unitOfWork.MentorTeachingProposals.Query() - .AsNoTracking() - .CountAsync(p => p.MentorId == mentorId - && !p.IsHiddenFromMentorHistory - && (p.Status == MentorTeachingProposalStatus.ChangesRequested - || (p.Status == MentorTeachingProposalStatus.Approved - && !linkedCohortProposalIds.Contains(p.Id))), - ct); + .CountAsync(x => x.MentorId == mentorId && x.Status == StudyCohortMentorInvitation.Pending, ct); response.Counters.Add(new SidebarCounterItemDto { Key = "mentor.proposals_action_required", - Count = Math.Max(0, proposalsActionRequired), + Count = 0, + Kind = SidebarCounterKind.ActionRequired, + }); + response.Counters.Add(new SidebarCounterItemDto + { + Key = "mentor.cohort_invitations_pending", Count = pendingCohortInvitations, Kind = SidebarCounterKind.ActionRequired, }); @@ -324,9 +337,7 @@ private async Task PopulateAdminCountersAsync( Kind = SidebarCounterKind.ActionRequired, }); - var pendingProposals = await unitOfWork.MentorTeachingProposals.Query() - .AsNoTracking() - .CountAsync(p => p.Status == MentorTeachingProposalStatus.PendingReview, ct); + var pendingProposals = 0; // Exclude slots owned by a proposal so 1 proposal with multiple sessions is never counted multiple times. var pendingStandaloneSlots = await unitOfWork.MentorAvailabilities.Query() @@ -335,7 +346,8 @@ private async Task PopulateAdminCountersAsync( && x.TeachingProposalId == null && !x.IsApproved && x.RejectedAt == null - && x.StartTime > utcNow, + && x.StartTime > utcNow + && !unitOfWork.StudyCohorts.Query().Any(c => c.Sessions.Any(s => s.AvailabilityId == x.Id)), ct); response.Counters.Add(new SidebarCounterItemDto @@ -349,6 +361,14 @@ private async Task PopulateAdminCountersAsync( ["pendingStandaloneSlots"] = pendingStandaloneSlots, }, }); + var mentorChangeRequests = await unitOfWork.StudyCohortMentorInvitations.Query().AsNoTracking() + .CountAsync(x => x.Status == StudyCohortMentorInvitation.ChangeRequested + || (x.Status == StudyCohortMentorInvitation.Declined && x.Cohort.Status == "Draft"), ct); + response.Counters.Add(new SidebarCounterItemDto + { + Key = "admin.cohort_mentor_changes", Count = mentorChangeRequests, + Kind = SidebarCounterKind.ActionRequired, + }); var pendingCohortScheduleRequests = await unitOfWork.CohortScheduleRequests.Query() .AsNoTracking() diff --git a/RikiPath.Application/Services/StudyCohortLifecycleService.cs b/RikiPath.Application/Services/StudyCohortLifecycleService.cs index c577a892..04e1d7b3 100644 --- a/RikiPath.Application/Services/StudyCohortLifecycleService.cs +++ b/RikiPath.Application/Services/StudyCohortLifecycleService.cs @@ -140,7 +140,7 @@ private object CohortSchedulePreview(CohortScheduleEvaluation e, bool includeCou { CourseId = includeCourseIds ? b.CourseId : (int?)null, b.Kind, b.PaymentStatus, b.Status, b.PaymentExpiresAt }).ToList(), - SessionCount = c.Sessions.Count, c.Plan?.SessionsPerWeek, + SessionCount = c.Sessions.Count, SessionsPerWeek = c.Sessions.Select(s => s.Availability.StartTime.DayOfWeek).Distinct().Count(), CurrentStartsAt = c.StartsAt, CurrentEndsAt = c.EndsAt, ProposedStartsAt = e.Shifted.Count == 0 ? (DateTime?)null : c.StartsAt.AddDays(7 * e.Weeks!.Value), ProposedEndsAt = e.Shifted.Count == 0 ? (DateTime?)null : c.EndsAt.AddDays(7 * e.Weeks!.Value), @@ -209,6 +209,8 @@ public Task> CreateCohortScheduleRequestAsync(int cohortId, int? weeks = kind == CohortScheduleRequest.KindShiftWeeks ? r.ShiftWeeks ?? 1 : null; Rule(weeks is null || weeks is >= 1 and <= MaxCohortShiftWeeks, "COHORT_SHIFT_WEEKS_INVALID", $"Số tuần dời phải từ 1 đến {MaxCohortShiftWeeks}."); + Rule(kind != CohortScheduleRequest.KindShiftWeeks || Actor.Role == Role.Admin, + "MENTOR_SCHEDULE_CHANGE_REQUIRES_REPLACEMENT", "Mentor đổi lịch lớp cần gửi yêu cầu đổi người dạy để Admin phân công mentor thay thế."); var reason = r.Reason?.Trim() ?? ""; Rule(reason.Length is >= 10 and <= 1000, "COHORT_SCHEDULE_REQUEST_REASON_REQUIRED", "Nhập lý do từ 10 đến 1000 ký tự."); Rule(r.IdempotencyKey != Guid.Empty, "COHORT_SCHEDULE_IDEMPOTENCY_KEY_REQUIRED", "Thiếu mã chống gửi trùng."); diff --git a/RikiPath.Application/Services/StudyCohortMentorInvitationService.cs b/RikiPath.Application/Services/StudyCohortMentorInvitationService.cs new file mode 100644 index 00000000..5455d8f0 --- /dev/null +++ b/RikiPath.Application/Services/StudyCohortMentorInvitationService.cs @@ -0,0 +1,567 @@ +using System.Net; +using Microsoft.EntityFrameworkCore; +using RikiPath.Application.IServices; +using RikiPath.Application.Requests.StudyCourses; +using RikiPath.Application.Responses; +using RikiPath.Domain.Entities; +using RikiPath.Domain.Enums; +using RikiPath.Domain.MentorScheduling; + +namespace RikiPath.Application.Services; + +public sealed partial class StudyCourseService +{ + private static object InvitationView(StudyCohortMentorInvitation x) => new + { + x.Id, x.CohortId, CohortName = x.Cohort.Name, CohortStatus = x.Cohort.Status, + x.Cohort.Level, x.Cohort.Capacity, x.Cohort.CourseDurationWeeks, CohortRevision = x.Cohort.Revision, + x.MentorId, MentorName = $"{x.Mentor.FirstName} {x.Mentor.LastName}".Trim(), + x.AssignedByAdminId, x.Status, x.DeclineReason, x.ChangeReason, x.AssignmentReason, + x.FromSessionNumber, x.CohortRevisionAtInvite, x.CreatedAtUtc, x.RespondedAtUtc, x.Revision, + Sessions = x.Cohort.Sessions.Where(s => !x.FromSessionNumber.HasValue || s.Number >= x.FromSessionNumber.Value) + .OrderBy(s => s.Number).Select(s => new + { + s.Number, StartsAtUtc = s.Availability.StartTime, EndsAtUtc = s.Availability.EndTime + }).ToList() + }; + + private IQueryable InvitationDetails => uow.StudyCohortMentorInvitations.Query() + .Include(x => x.Cohort).ThenInclude(c => c.Sessions).ThenInclude(s => s.Availability) + .Include(x => x.Mentor).AsSplitQuery(); + + private static bool MatchesCreationRequest(StudyCohortMentorInvitation existing, CreateAdminCohortRequest request, string name) + { + if (existing.AssignmentReason is not null || existing.MentorId != request.MentorId + || existing.Cohort.Level != (request.Level?.Trim().ToUpperInvariant() ?? "") || existing.Cohort.Name != name + || existing.Cohort.Capacity != request.Capacity || existing.Cohort.TotalTuitionSnapshot != request.Price + || existing.Cohort.CourseDurationWeeks != request.CourseDurationWeeks + || request.Sessions is not { Count: > 0 } || existing.Cohort.Sessions.Count != request.Sessions.Count) + return false; + var requested = request.Sessions.OrderBy(x => x.StartsAtUtc).ToList(); + var stored = existing.Cohort.Sessions.OrderBy(x => x.Number).ToList(); + return stored.Zip(requested).All(pair => pair.First.Availability.StartTime == pair.Second.StartsAtUtc + && pair.First.Availability.EndTime == pair.Second.EndsAtUtc) + && existing.Cohort.EnrollmentClosesAtUtc == + (request.EnrollmentClosesAtUtc ?? requested[0].StartsAtUtc); + } + + private async Task<(string Level, List Sessions, MentorGroupPolicy Policy)> + ValidateAdminCohortScheduleAsync(string? requestedLevel, int capacity, decimal price, int durationWeeks, + IReadOnlyList? sessions, CancellationToken ct) + { + Rule(sessions is { Count: > 0 and <= 500 }, "COHORT_SESSIONS_REQUIRED", + "Nhập từ 1 đến 500 buổi học."); + var level = requestedLevel?.Trim().ToUpperInvariant() ?? ""; + Rule(MentorSlotPolicy.IsSupportedClassLevel(level) && await uow.CertificateLevels.Query().AnyAsync(x => x.Code == level + && !x.IsDeleted && !x.CertificateType.IsDeleted && x.CertificateType.IsActive, ct), + "COHORT_LEVEL_INVALID", "Chọn cấp độ lớp đang hoạt động."); + if (durationWeeks > 0) + { + Rule(durationWeeks <= 52, "COHORT_DURATION_INVALID", "Thời gian lớp phải từ 1 đến 52 tuần."); + Rule(price > 0 && price == decimal.Truncate(price) && price <= int.MaxValue, + "COHORT_PRICE_INVALID", "Học phí lớp phải là số VND dương trong giới hạn thanh toán."); + } + var ordered = sessions!.OrderBy(x => x.StartsAtUtc).ToList(); + var now = DateTime.UtcNow; + Rule(ordered.All(s => s.StartsAtUtc.Kind == DateTimeKind.Utc && s.EndsAtUtc.Kind == DateTimeKind.Utc + && s.StartsAtUtc > now && s.EndsAtUtc > s.StartsAtUtc + && (s.EndsAtUtc - s.StartsAtUtc).TotalMinutes is >= 30 and <= 360 + && s.StartsAtUtc.AddHours(7).Date == s.EndsAtUtc.AddHours(7).Date + && s.StartsAtUtc.TimeOfDay == ordered[0].StartsAtUtc.TimeOfDay + && s.EndsAtUtc.TimeOfDay == ordered[0].EndsAtUtc.TimeOfDay), + "COHORT_SESSION_TIME_INVALID", "Mọi ngày học phải dùng cùng giờ bắt đầu và kết thúc, trong cùng ngày (30–360 phút)."); + Rule(ordered.Zip(ordered.Skip(1)).All(pair => pair.First.EndsAtUtc <= pair.Second.StartsAtUtc), + "COHORT_SESSION_OVERLAP", "Các buổi học không được trùng nhau."); + if (durationWeeks > 0) + { + Rule(ordered.Count % durationWeeks == 0, "COHORT_WEEKLY_PATTERN_INVALID", + "Lịch học phải lặp lại đủ số ngày trong mỗi tuần."); + var perWeek = ordered.Count / durationWeeks; + Rule(perWeek is >= 1 and <= 7 && ordered.Take(perWeek).Select(s => s.StartsAtUtc.DayOfWeek).Distinct().Count() == perWeek + && ordered.Select((s, i) => (Session: s, Index: i)).All(x => + x.Session.StartsAtUtc == ordered[x.Index % perWeek].StartsAtUtc.AddDays(7 * (x.Index / perWeek)) + && x.Session.EndsAtUtc == ordered[x.Index % perWeek].EndsAtUtc.AddDays(7 * (x.Index / perWeek))), + "COHORT_WEEKLY_PATTERN_INVALID", "Lịch học phải lặp đúng thứ và khung giờ trong từng tuần."); + } + var policy = await CurrentPolicyAsync(ct); + if (durationWeeks > 0) + Rule(capacity is >= 1 and <= 50, + "COHORT_CAPACITY_INVALID", "Sĩ số lớp phải từ 1 đến 50 học viên."); + return (level, ordered, policy); + } + + private async Task QualifiedForCohortAsync(int mentorId, string level, CancellationToken ct) + { + var mentor = await uow.UserAccounts.Query().AsNoTracking().Include(x => x.MentorProfile) + .SingleOrDefaultAsync(x => x.Id == mentorId && x.Role == Role.Mentor && !x.IsDeleted, ct); + if (mentor?.MentorProfile?.VerificationStatus != MentorVerificationStatus.Approved) return false; + var qualifiedCodes = await uow.MentorTeachingQualifications.Query().AsNoTracking() + .Where(x => x.MentorUserId == mentorId && x.IsActive && x.RevokedAtUtc == null) + .Select(x => x.CertificateLevel.Code).ToListAsync(ct); + var direct = qualifiedCodes.Any(x => string.Equals(x, level, StringComparison.OrdinalIgnoreCase)); + var rank = qualifiedCodes.Append(mentor.MentorProfile.JlptLevel) + .Select(MentorSlotPolicy.GetJlptRank).DefaultIfEmpty(0).Max(); + return direct || MentorSlotPolicy.CanMentorTeachLevel(rank, level); + } + + private async Task EnsureEligibleMentorAsync(int mentorId, string level, + IReadOnlyList sessions, int? excludeCohortId, CancellationToken ct) + { + Rule(await QualifiedForCohortAsync(mentorId, level, ct), "COHORT_MENTOR_NOT_QUALIFIED", + "Mentor chưa được xác minh hoặc chưa đủ cấp độ để dạy lớp."); + await EnsureNoTeachingConflictAsync(mentorId, + sessions.Select((s, i) => new ProposedTeachingInterval(s.StartsAtUtc, s.EndsAtUtc, i + 1)).ToList(), + new TeachingConflictOptions { ExcludeCohortId = excludeCohortId }, ct); + } + + public Task> AdminCohortMentorCandidatesAsync(AdminCohortMentorCandidatesRequest r, CancellationToken ct) + => Run(async () => + { + Admin(); + var (level, sessions, _) = await ValidateAdminCohortScheduleAsync(r.Level, 0, 0, 0, r.Sessions, ct); + var mentors = await uow.UserAccounts.Query().AsNoTracking().Include(x => x.MentorProfile) + .Where(x => x.Role == Role.Mentor && !x.IsDeleted && x.MentorProfile != null + && x.MentorProfile.VerificationStatus == MentorVerificationStatus.Approved) + .OrderBy(x => x.Id).ToListAsync(ct); + var result = new List(); + foreach (var mentor in mentors) + { + if (!await QualifiedForCohortAsync(mentor.Id, level, ct)) continue; + var report = await TeachingConflicts.CheckAsync(mentor.Id, + sessions.Select((s, i) => new ProposedTeachingInterval(s.StartsAtUtc, s.EndsAtUtc, i + 1)).ToList(), + null, ct); + if (report.IsValid) + result.Add(new { MentorId = mentor.Id, Name = $"{mentor.FirstName} {mentor.LastName}".Trim(), + Level = mentor.MentorProfile?.JlptLevel }); + } + return (object)result; + }); + + public Task> CreateAdminCohortAsync(CreateAdminCohortRequest r, CancellationToken ct) + => Run(async () => + { + Admin(); + Rule(r.IdempotencyKey != Guid.Empty, "COHORT_IDEMPOTENCY_KEY_REQUIRED", "Thiếu mã chống gửi trùng."); + Rule(r.CourseDurationWeeks is >= 1 and <= 52, "COHORT_DURATION_INVALID", "Thời gian lớp phải từ 1 đến 52 tuần."); + var name = r.Name?.Trim() ?? ""; + Rule(name.Length is >= 3 and <= 200, "COHORT_NAME_INVALID", "Tên lớp phải từ 3 đến 200 ký tự."); + var prior = await InvitationDetails.AsNoTracking() + .SingleOrDefaultAsync(x => x.IdempotencyKey == r.IdempotencyKey, ct); + if (prior is not null) + { + Rule(MatchesCreationRequest(prior, r, name), "COHORT_IDEMPOTENCY_KEY_REUSED", + "Mã chống gửi trùng đã dùng cho lịch/lớp khác.", HttpStatusCode.Conflict); + return (object)new { prior.CohortId, InvitationId = prior.Id, prior.Status, Idempotent = true }; + } + var (level, sessions, policy) = await ValidateAdminCohortScheduleAsync(r.Level, r.Capacity, + r.Price, r.CourseDurationWeeks, r.Sessions, ct); + var defaultCutoff = sessions[0].StartsAtUtc; + Rule(!r.EnrollmentClosesAtUtc.HasValue || (r.EnrollmentClosesAtUtc.Value.Kind == DateTimeKind.Utc + && r.EnrollmentClosesAtUtc.Value > DateTime.UtcNow + && r.EnrollmentClosesAtUtc.Value <= defaultCutoff), + "COHORT_ENROLLMENT_CUTOFF_INVALID", "Hạn đăng ký phải sau hiện tại và không muộn hơn buổi đầu tiên."); + object result = new { }; + await uow.ExecuteInTransactionAsync(async token => + { + var existing = await InvitationDetails.AsNoTracking() + .SingleOrDefaultAsync(x => x.IdempotencyKey == r.IdempotencyKey, token); + if (existing is not null) + { + Rule(MatchesCreationRequest(existing, r, name), "COHORT_IDEMPOTENCY_KEY_REUSED", + "Mã chống gửi trùng đã dùng cho lịch/lớp khác.", HttpStatusCode.Conflict); + result = new { existing.CohortId, InvitationId = existing.Id, existing.Status, Idempotent = true }; + return; + } + await uow.StudyCourses.LockScheduleAsync(r.MentorId, r.MentorId, token); + await EnsureEligibleMentorAsync(r.MentorId, level, sessions, null, token); + var now = DateTime.UtcNow; + var cohort = new StudyCohort + { + Level = level, Name = name, MentorId = r.MentorId, Capacity = r.Capacity, + CapacitySnapshot = r.Capacity, StartsAt = sessions[0].StartsAtUtc, + EndsAt = sessions[^1].EndsAtUtc, Status = "Draft", Revision = 1, + GroupPolicyId = policy.Id == 0 ? null : policy.Id, PolicyVersionSnapshot = policy.Version, + CourseDurationWeeks = r.CourseDurationWeeks, + EnrollmentClosesAtUtc = r.EnrollmentClosesAtUtc ?? defaultCutoff, + TotalTuitionSnapshot = r.Price, + CreatedAtUtc = now + }; + foreach (var (session, index) in sessions.Select((s, i) => (s, i))) + { + cohort.Sessions.Add(new StudyCohortSession + { + Number = index + 1, + Availability = new MentorAvailability + { + MentorId = r.MentorId, StartTime = session.StartsAtUtc, EndTime = session.EndsAtUtc, + MaxLearners = r.Capacity, IsApproved = false, CreatedDate = now + } + }); + } + await uow.StudyCohorts.AddAsync(cohort, token); + await uow.SaveChangesAsync(token); + var invitation = new StudyCohortMentorInvitation + { + CohortId = cohort.Id, MentorId = r.MentorId, AssignedByAdminId = Actor.Id, + IdempotencyKey = r.IdempotencyKey, CohortRevisionAtInvite = cohort.Revision, + CreatedAtUtc = now + }; + await uow.StudyCohortMentorInvitations.AddAsync(invitation, token); + await uow.SaveChangesAsync(token); + QueueNotifications($"cohort-mentor-invitation:{invitation.Id}", "StudyCohortMentorInvitation", + invitation.Id.ToString(), + [(r.MentorId, "Lời mời dạy lớp", $"Admin mời bạn dạy lớp {cohort.Name}. Hãy phản hồi lịch dạy.", + "CohortMentorInvitation", (string?)$"/mentor/cohorts/{cohort.Id}?invitationId={invitation.Id}")]); + await uow.SaveChangesAsync(token); + result = new { CohortId = cohort.Id, InvitationId = invitation.Id, Status = invitation.Status, + CohortStatus = cohort.Status, Idempotent = false }; + }, ct); + await NotifyUsersCounterAsync([r.MentorId], "cohort_mentor_invitation_created", ct); + return result; + }); + + public Task> CohortMentorInvitationsAsync(int? cohortId, CancellationToken ct) + => Run(async () => + { + Rule(Actor.Role is Role.Admin or Role.Mentor, "INVITATION_FORBIDDEN", "Không có quyền xem lời mời.", HttpStatusCode.Forbidden); + var query = InvitationDetails.Where(x => Actor.Role == Role.Admin || x.MentorId == Actor.Id); + if (cohortId.HasValue) query = query.Where(x => x.CohortId == cohortId.Value); + var rows = await query.OrderByDescending(x => x.Id).Take(500).ToListAsync(ct); + return (object)rows.Select(InvitationView).ToList(); + }); + + public Task> InviteCohortMentorAsync(int cohortId, InviteCohortMentorRequest r, CancellationToken ct) + => Run(async () => + { + Admin(); + Rule(r.IdempotencyKey != Guid.Empty, "INVITATION_IDEMPOTENCY_KEY_REQUIRED", "Thiếu mã chống gửi trùng."); + var reason = r.Reason?.Trim() ?? ""; + Rule(reason.Length is >= 10 and <= 1000, "INVITATION_REASON_REQUIRED", "Nhập lý do phân công từ 10 đến 1000 ký tự."); + object result = new { }; + await uow.ExecuteInTransactionAsync(async token => + { + var existing = await uow.StudyCohortMentorInvitations.Query().AsNoTracking() + .SingleOrDefaultAsync(x => x.IdempotencyKey == r.IdempotencyKey, token); + if (existing is not null) + { + Rule(existing.CohortId == cohortId && existing.MentorId == r.MentorId + && existing.AssignmentReason == reason + && existing.CohortRevisionAtInvite == r.ExpectedCohortRevision + + (existing.FromSessionNumber.HasValue ? 0 : 1) + && (!r.FromSessionNumber.HasValue || existing.FromSessionNumber == r.FromSessionNumber), + "INVITATION_IDEMPOTENCY_KEY_REUSED", "Mã chống gửi trùng đã dùng cho lời mời khác.", HttpStatusCode.Conflict); + result = new { InvitationId = existing.Id, existing.CohortId, existing.Status, Idempotent = true }; + return; + } + await uow.StudyCourses.LockCohortAsync(cohortId, token); + var cohort = await uow.StudyCohorts.Query() + .Include(x => x.Sessions).ThenInclude(x => x.Availability) + .SingleOrDefaultAsync(x => x.Id == cohortId, token); + Rule(cohort is not null, "COHORT_NOT_FOUND", "Không tìm thấy lớp.", HttpStatusCode.NotFound); + Rule(cohort!.Status is "Draft" or "Published", "COHORT_NOT_ACTIVE", "Lớp không còn nhận phân công.", HttpStatusCode.Conflict); + Rule(cohort.Revision == r.ExpectedCohortRevision, "COHORT_STALE", "Lớp vừa thay đổi, hãy tải lại.", HttpStatusCode.Conflict); + Rule(cohort.Sessions.Count > 0, "COHORT_NO_SESSIONS", "Lớp chưa có lịch học.", HttpStatusCode.Conflict); + if (cohort.Status == "Draft") + Rule(cohort.Sessions.All(s => s.Availability.StartTime > DateTime.UtcNow), + "COHORT_ALREADY_STARTED", "Lịch lớp nháp đã bắt đầu; admin cần tạo lịch mới.", HttpStatusCode.Conflict); + Rule(!await uow.StudyCohortMentorInvitations.Query().AnyAsync(x => x.CohortId == cohortId + && x.Status == StudyCohortMentorInvitation.Pending, token), "INVITATION_ALREADY_PENDING", + "Lớp đã có lời mời mentor đang chờ phản hồi.", HttpStatusCode.Conflict); + Rule(r.MentorId != cohort.MentorId || cohort.Status == "Draft", + "INVITATION_SAME_MENTOR", "Chọn mentor khác mentor đang dạy."); + if (cohort.Status == "Draft") + Rule(!await uow.StudyCohortMentorInvitations.Query().AnyAsync(x => x.CohortId == cohortId + && x.MentorId == r.MentorId && x.Status == StudyCohortMentorInvitation.Declined, token), + "MENTOR_ALREADY_DECLINED", "Mentor này đã từ chối lớp.", HttpStatusCode.Conflict); + await uow.StudyCourses.LockScheduleAsync(r.MentorId, cohort.MentorId, token); + var evaluation = cohort.Status == "Published" + ? await EvaluateReplacementAsync(cohortId, r.MentorId, r.FromSessionNumber, token) + : null; + if (evaluation?.FirstFailure is { } failure) + throw new CourseRuleException(failure.Message, (HttpStatusCode)failure.Status, failure.Code); + var affected = cohort.Status == "Draft" + ? cohort.Sessions.OrderBy(s => s.Number).ToList() + : evaluation!.Affected; + Rule(affected.Count > 0, "INVITATION_NO_SESSIONS", "Không còn buổi để phân công."); + var times = affected.Select(s => new AdminCohortSessionTime(s.Availability.StartTime, s.Availability.EndTime)).ToList(); + await EnsureEligibleMentorAsync(r.MentorId, cohort.Level, times, cohort.Id, token); + if (cohort.Status == "Draft") + { + foreach (var session in cohort.Sessions) + { + var old = session.Availability; + old.IsDeleted = true; + old.ModifiedDate = DateTime.UtcNow; + session.Availability = new MentorAvailability + { + MentorId = r.MentorId, StartTime = old.StartTime, EndTime = old.EndTime, + MaxLearners = old.MaxLearners, IsApproved = false, GroupPolicyId = old.GroupPolicyId, + PolicyVersion = old.PolicyVersion, SessionMinutesSnapshot = old.SessionMinutesSnapshot, + RestMinutesSnapshot = old.RestMinutesSnapshot, CreatedDate = DateTime.UtcNow + }; + } + cohort.MentorId = r.MentorId; + cohort.Revision++; + } + var invitation = new StudyCohortMentorInvitation + { + CohortId = cohort.Id, MentorId = r.MentorId, AssignedByAdminId = Actor.Id, + AssignmentReason = reason, FromSessionNumber = cohort.Status == "Draft" ? null : evaluation!.FromSessionNumber, + CohortRevisionAtInvite = cohort.Revision, + IdempotencyKey = r.IdempotencyKey + }; + await uow.StudyCohortMentorInvitations.AddAsync(invitation, token); + await uow.SaveChangesAsync(token); + QueueNotifications($"cohort-mentor-invitation:{invitation.Id}", "StudyCohortMentorInvitation", + invitation.Id.ToString(), + [(r.MentorId, "Lời mời dạy lớp", $"Admin mời bạn dạy lớp {cohort.Name}. Hãy phản hồi lịch dạy.", + "CohortMentorInvitation", (string?)$"/mentor/cohorts/{cohort.Id}?invitationId={invitation.Id}")]); + await uow.SaveChangesAsync(token); + result = new { InvitationId = invitation.Id, cohort.Id, invitation.Status, CohortRevision = cohort.Revision, + Idempotent = false }; + }, ct); + await NotifyUsersCounterAsync([r.MentorId], "cohort_mentor_invitation_created", ct); + return result; + }); + + public Task> DeclineCohortMentorInvitationAsync(int invitationId, + DeclineCohortInvitationRequest r, CancellationToken ct) => Run(async () => + { + Rule(Actor.Role == Role.Mentor, "INVITATION_FORBIDDEN", "Chỉ mentor được phản hồi.", HttpStatusCode.Forbidden); + var reason = r.Reason?.Trim() ?? ""; + Rule(reason.Length is >= 3 and <= 1000, "DECLINE_REASON_REQUIRED", "Nhập lý do từ chối từ 3 đến 1000 ký tự."); + object result = new { }; + await uow.ExecuteInTransactionAsync(async token => + { + var header = await uow.StudyCohortMentorInvitations.Query().AsNoTracking() + .Where(x => x.Id == invitationId).Select(x => new { x.CohortId, x.MentorId }).SingleOrDefaultAsync(token); + Rule(header is not null, "INVITATION_NOT_FOUND", "Không tìm thấy lời mời.", HttpStatusCode.NotFound); + Rule(header!.MentorId == Actor.Id, "INVITATION_FORBIDDEN", "Không phải lời mời của bạn.", HttpStatusCode.Forbidden); + await uow.StudyCourses.LockCohortAsync(header.CohortId, token); + var invitation = await uow.StudyCohortMentorInvitations.Query().Include(x => x.Cohort) + .ThenInclude(x => x.Sessions).ThenInclude(x => x.Availability) + .SingleAsync(x => x.Id == invitationId, token); + if (invitation.Status == StudyCohortMentorInvitation.Declined) + { + result = new { invitation.Id, invitation.Status, invitation.DeclineReason, Idempotent = true }; return; + } + Rule(invitation.Status == StudyCohortMentorInvitation.Pending, "INVITATION_NOT_PENDING", + "Lời mời đã được xử lý.", HttpStatusCode.Conflict); + invitation.Status = StudyCohortMentorInvitation.Declined; + invitation.DeclineReason = reason; + invitation.RespondedAtUtc = DateTime.UtcNow; + invitation.Revision++; + if (invitation.Cohort.Status == "Draft") + { + foreach (var session in invitation.Cohort.Sessions) + { + session.Availability.IsDeleted = true; + session.Availability.ModifiedDate = DateTime.UtcNow; + } + invitation.Cohort.Revision++; + } + var admins = await uow.UserAccounts.Query().Where(x => x.Role == Role.Admin && !x.IsDeleted) + .Select(x => x.Id).ToListAsync(token); + QueueNotifications($"cohort-mentor-invitation:{invitation.Id}:declined", "StudyCohortMentorInvitation", + invitation.Id.ToString(), admins.Select(id => (id, "Mentor từ chối lớp", + $"Mentor đã từ chối lớp {invitation.Cohort.Name}. Lý do: {reason}", "CohortMentorInvitation", + (string?)$"/admin/study-courses?cohortId={invitation.CohortId}&invitationId={invitation.Id}"))); + await uow.SaveChangesAsync(token); + result = new { invitation.Id, invitation.Status, invitation.DeclineReason, Idempotent = false }; + }, ct); + await NotifyAdminsCounterAsync("cohort_mentor_invitation_declined", ct); + await NotifyUsersCounterAsync([Actor.Id], "cohort_mentor_invitation_declined", ct); + return result; + }); + + public Task> RequestCohortMentorChangeAsync(int cohortId, + RequestCohortMentorChangeRequest r, CancellationToken ct) => Run(async () => + { + Rule(Actor.Role == Role.Mentor, "MENTOR_CHANGE_FORBIDDEN", "Chỉ mentor phụ trách được yêu cầu đổi lịch.", HttpStatusCode.Forbidden); + var reason = r.Reason?.Trim() ?? ""; + Rule(reason.Length is >= 3 and <= 1000, "MENTOR_CHANGE_REASON_REQUIRED", "Nhập lý do đổi lịch từ 3 đến 1000 ký tự."); + object result = new { }; + await uow.ExecuteInTransactionAsync(async token => + { + await uow.StudyCourses.LockCohortAsync(cohortId, token); + var cohort = await uow.StudyCohorts.Query().SingleOrDefaultAsync(x => x.Id == cohortId, token); + Rule(cohort is not null, "COHORT_NOT_FOUND", "Không tìm thấy lớp.", HttpStatusCode.NotFound); + Rule(cohort!.MentorId == Actor.Id && cohort.Status == "Published", "MENTOR_CHANGE_FORBIDDEN", + "Bạn không phụ trách lớp đang mở này.", HttpStatusCode.Forbidden); + var invitation = await uow.StudyCohortMentorInvitations.Query() + .Where(x => x.CohortId == cohortId && x.MentorId == Actor.Id + && (x.Status == StudyCohortMentorInvitation.Accepted + || x.Status == StudyCohortMentorInvitation.ChangeRequested)) + .OrderByDescending(x => x.Id).FirstOrDefaultAsync(token); + if (invitation is null) + { + invitation = new StudyCohortMentorInvitation + { + CohortId = cohortId, MentorId = Actor.Id, AssignedByAdminId = null, + Status = StudyCohortMentorInvitation.Accepted, + AssignmentReason = "Phân công lớp có trước quy trình xác nhận mentor.", + IdempotencyKey = Guid.NewGuid(), CohortRevisionAtInvite = cohort.Revision, + RespondedAtUtc = DateTime.UtcNow + }; + await uow.StudyCohortMentorInvitations.AddAsync(invitation, token); + await uow.SaveChangesAsync(token); + } + if (invitation.Status == StudyCohortMentorInvitation.ChangeRequested) + { + result = new { invitation.Id, invitation.Status, Idempotent = true }; return; + } + invitation.Status = StudyCohortMentorInvitation.ChangeRequested; + invitation.ChangeReason = reason; + invitation.Revision++; + var admins = await uow.UserAccounts.Query().Where(x => x.Role == Role.Admin && !x.IsDeleted) + .Select(x => x.Id).ToListAsync(token); + QueueNotifications($"cohort-mentor-invitation:{invitation.Id}:change", "StudyCohortMentorInvitation", + invitation.Id.ToString(), admins.Select(id => (id, "Mentor yêu cầu đổi lịch dạy", + $"Mentor xin đổi lịch lớp {cohort.Name}. Lý do: {reason}", "CohortMentorChange", + (string?)$"/admin/study-courses?cohortId={cohortId}&invitationId={invitation.Id}"))); + await uow.SaveChangesAsync(token); + result = new { invitation.Id, invitation.Status, invitation.ChangeReason, Idempotent = false }; + }, ct); + await NotifyAdminsCounterAsync("cohort_mentor_change_requested", ct); + return result; + }); + + public Task> CancelCohortMentorInvitationAsync(int invitationId, CancellationToken ct) + => Run(async () => + { + Admin(); + object result = new { }; + var mentorIdToNotify = 0; + await uow.ExecuteInTransactionAsync(async token => + { + var header = await uow.StudyCohortMentorInvitations.Query().AsNoTracking() + .Where(x => x.Id == invitationId).Select(x => new { x.CohortId, x.MentorId }).SingleOrDefaultAsync(token); + Rule(header is not null, "INVITATION_NOT_FOUND", "Không tìm thấy lời mời.", HttpStatusCode.NotFound); + mentorIdToNotify = header!.MentorId; + await uow.StudyCourses.LockCohortAsync(header!.CohortId, token); + var invitation = await uow.StudyCohortMentorInvitations.Query() + .Include(x => x.Cohort).ThenInclude(x => x.Sessions).ThenInclude(x => x.Availability) + .SingleAsync(x => x.Id == invitationId, token); + if (invitation.Status == StudyCohortMentorInvitation.Cancelled) + { result = new { invitation.Id, invitation.Status, Idempotent = true }; return; } + Rule(invitation.Status == StudyCohortMentorInvitation.Pending, "INVITATION_NOT_PENDING", + "Lời mời đã được xử lý.", HttpStatusCode.Conflict); + invitation.Status = StudyCohortMentorInvitation.Cancelled; + invitation.RespondedAtUtc = DateTime.UtcNow; + invitation.Revision++; + if (invitation.Cohort.Status == "Draft" && invitation.Cohort.MentorId == invitation.MentorId) + { + foreach (var session in invitation.Cohort.Sessions) + { + session.Availability.IsDeleted = true; + session.Availability.ModifiedDate = DateTime.UtcNow; + } + invitation.Cohort.Revision++; + } + QueueNotifications($"cohort-mentor-invitation:{invitation.Id}:cancelled", "StudyCohortMentorInvitation", + invitation.Id.ToString(), + [(invitation.MentorId, "Lời mời dạy lớp đã hủy", + $"Lời mời dạy lớp {invitation.Cohort.Name} không còn hiệu lực.", + "CohortMentorInvitation", (string?)$"/mentor/cohorts/{invitation.CohortId}?invitationId={invitation.Id}")]); + await uow.SaveChangesAsync(token); + result = new { invitation.Id, invitation.Status, Idempotent = false }; + }, ct); + await NotifyUsersCounterAsync([mentorIdToNotify], "cohort_mentor_invitation_cancelled", ct); + return result; + }); + + public Task> ReplaceCohortMentorAsync(int cohortId, ReplaceCohortMentorRequest r, CancellationToken ct) + => InviteCohortMentorAsync(cohortId, + new InviteCohortMentorRequest(r.MentorId, r.Reason, r.IdempotencyKey, + r.ExpectedCohortRevision, r.FromSessionNumber), ct); + + public async Task> AcceptCohortMentorInvitationAsync(int invitationId, CancellationToken ct) + { + if (Actor.Role != Role.Mentor) + return ApiResponse.Fail("Chỉ mentor được phản hồi lời mời.", HttpStatusCode.Forbidden); + var invitation = await uow.StudyCohortMentorInvitations.Query().AsNoTracking() + .Include(x => x.Cohort).SingleOrDefaultAsync(x => x.Id == invitationId, ct); + if (invitation is null) + return ApiResponse.Fail("Không tìm thấy lời mời.", HttpStatusCode.NotFound); + if (invitation.MentorId != Actor.Id) + return ApiResponse.Fail("Không phải lời mời của bạn.", HttpStatusCode.Forbidden); + if (invitation.Status == StudyCohortMentorInvitation.Accepted) + return ApiResponse.Success(new { invitation.Id, invitation.Status, Idempotent = true }); + if (invitation.Status != StudyCohortMentorInvitation.Pending) + return ApiResponse.Fail("Lời mời đã được xử lý.", HttpStatusCode.Conflict); + + if (invitation.Cohort.Status == "Published") + { + var response = await CommitAcceptedMentorReplacementAsync(invitation.Id, invitation.CohortId, + new ReplaceCohortMentorRequest(invitation.MentorId, + invitation.AssignmentReason ?? "Mentor nhận phân công lớp.", invitation.IdempotencyKey, + invitation.CohortRevisionAtInvite, invitation.FromSessionNumber), + invitation.AssignedByAdminId ?? 0, ct); + if (response.IsSuccess) + { + await NotifyAdminsCounterAsync("cohort_mentor_invitation_accepted", ct); + await NotifyUsersCounterAsync([Actor.Id], "cohort_mentor_invitation_accepted", ct); + } + return response; + } + return await Run(async () => + { + object result = new { }; + await uow.ExecuteInTransactionAsync(async token => + { + await uow.StudyCourses.LockCohortAsync(invitation.CohortId, token); + await uow.StudyCourses.LockScheduleAsync(Actor.Id, Actor.Id, token); + var current = await uow.StudyCohortMentorInvitations.Query() + .Include(x => x.Cohort) + .Include(x => x.Cohort).ThenInclude(x => x.Sessions).ThenInclude(x => x.Availability) + .AsSplitQuery().SingleAsync(x => x.Id == invitationId, token); + if (current.Status == StudyCohortMentorInvitation.Accepted) + { + result = new { current.Id, current.Status, Idempotent = true }; return; + } + Rule(current.Status == StudyCohortMentorInvitation.Pending && current.MentorId == Actor.Id, + "INVITATION_NOT_PENDING", "Lời mời đã được xử lý.", HttpStatusCode.Conflict); + var cohort = current.Cohort; + Rule(cohort.Status == "Draft" && cohort.MentorId == Actor.Id, + "COHORT_NOT_AWAITING_MENTOR", "Lớp không còn chờ mentor này.", HttpStatusCode.Conflict); + Rule(cohort.Revision == current.CohortRevisionAtInvite, + "COHORT_STALE", "Lịch lớp đã thay đổi; admin cần gửi lời mời mới.", HttpStatusCode.Conflict); + var ordered = cohort.Sessions.OrderBy(s => s.Number).ToList(); + Rule(ordered.Count > 0 && ordered.All(s => !s.Availability.IsDeleted + && s.Availability.MentorId == Actor.Id && s.Availability.StartTime > DateTime.UtcNow), + "COHORT_SCHEDULE_INVALID", "Lịch lớp đã thay đổi hoặc đã bắt đầu.", HttpStatusCode.Conflict); + Rule(cohort.EnrollmentClosesAtUtc > DateTime.UtcNow, "COHORT_ENROLLMENT_CLOSED", + "Hạn đăng ký lớp đã qua; admin cần tạo lịch mới.", HttpStatusCode.Conflict); + await EnsureEligibleMentorAsync(Actor.Id, cohort.Level, + ordered.Select(s => new AdminCohortSessionTime(s.Availability.StartTime, s.Availability.EndTime)).ToList(), + cohort.Id, token); + var now = DateTime.UtcNow; + foreach (var session in ordered) + { + session.Availability.IsApproved = true; + session.Availability.AdminName = "Quản trị viên (mentor đã xác nhận)"; + session.Availability.PublishedAt = now; + } + cohort.Status = "Published"; + cohort.EnrollmentOpensAtUtc = now; + cohort.TuitionSnapshotAtUtc = now; + cohort.Revision++; + current.Status = StudyCohortMentorInvitation.Accepted; + current.RespondedAtUtc = now; + current.Revision++; + var admins = await uow.UserAccounts.Query().Where(x => x.Role == Role.Admin && !x.IsDeleted) + .Select(x => x.Id).ToListAsync(token); + QueueNotifications($"cohort-mentor-invitation:{current.Id}:accepted", "StudyCohortMentorInvitation", + current.Id.ToString(), admins.Select(id => (id, "Mentor đã nhận lớp", + $"Mentor đã đồng ý dạy lớp {cohort.Name}; lớp đã mở đăng ký.", + "CohortMentorInvitation", (string?)$"/admin/study-courses?cohortId={cohort.Id}&invitationId={current.Id}"))); + await uow.SaveChangesAsync(token); + result = new { current.Id, current.Status, CohortId = cohort.Id, CohortStatus = cohort.Status, + Idempotent = false }; + }, ct); + await NotifyAdminsCounterAsync("cohort_mentor_invitation_accepted", ct); + await NotifyUsersCounterAsync([Actor.Id], "cohort_mentor_invitation_accepted", ct); + return result; + }); + } +} diff --git a/RikiPath.Application/Services/StudyCohortMentorReplacementService.cs b/RikiPath.Application/Services/StudyCohortMentorReplacementService.cs index 071eea78..30e8c1ae 100644 --- a/RikiPath.Application/Services/StudyCohortMentorReplacementService.cs +++ b/RikiPath.Application/Services/StudyCohortMentorReplacementService.cs @@ -53,9 +53,9 @@ void Check(string code, bool passed, string message, HttpStatusCode status = Htt .Select(RikiPath.Domain.MentorScheduling.MentorSlotPolicy.GetJlptRank) .DefaultIfEmpty(0) .Max(); - var targetLevelCode = cohort.Plan.CertificateLevel?.Code; + var targetLevelCode = cohort.Level; var hasDirectQualification = uow.MentorTeachingQualifications is not null && await uow.MentorTeachingQualifications.Query() - .AnyAsync(q => q.MentorUserId == mentorId && q.CertificateLevelId == cohort.Plan.CertificateLevelId && q.IsActive && q.RevokedAtUtc == null, ct); + .AnyAsync(q => q.MentorUserId == mentorId && q.CertificateLevel.Code == targetLevelCode && q.IsActive && q.RevokedAtUtc == null, ct); var qualified = hasDirectQualification || RikiPath.Domain.MentorScheduling.MentorSlotPolicy.CanMentorTeachLevel(highestRank, targetLevelCode); Check("REPLACEMENT_LEVEL_NOT_QUALIFIED", qualified, $"Giáo viên thay thế chưa được cấp quyền giảng dạy cấp độ {targetLevelCode}."); @@ -121,7 +121,7 @@ public Task> PreviewMentorReplacementAsync(int cohortId, int CohortId = e.Cohort.Id, e.Cohort.Name, e.Cohort.Revision, e.Cohort.Capacity, CurrentMentorId = e.Cohort.MentorId, CurrentMentorName = $"{e.Cohort.Mentor?.FirstName} {e.Cohort.Mentor?.LastName}".Trim(), ReplacementMentorId = mentorId, ReplacementMentorName = e.Mentor is null ? null : $"{e.Mentor.FirstName} {e.Mentor.LastName}".Trim(), - Level = e.Cohort.Plan.CertificateLevel?.Code, PolicyVersion = e.Policy.Version, LeadHours = e.Policy.MentorReplacementLeadHours, + Level = e.Cohort.Level, PolicyVersion = e.Policy.Version, LeadHours = e.Policy.MentorReplacementLeadHours, e.FromSessionNumber, e.Eligible, Impact = new { @@ -152,9 +152,11 @@ public Task> MentorAssignmentsAsync(int cohortId, Cancellati }).ToList(); }); - public Task> ReplaceCohortMentorAsync(int cohortId, ReplaceCohortMentorRequest r, CancellationToken ct) => Run(async () => + private Task> CommitAcceptedMentorReplacementAsync(int invitationId, int cohortId, + ReplaceCohortMentorRequest r, int assignedByAdminId, CancellationToken ct) => Run(async () => { - Admin(); + Rule(Actor.Role == Role.Mentor && Actor.Id == r.MentorId, "INVITATION_FORBIDDEN", + "Chỉ mentor được mời mới có thể xác nhận.", HttpStatusCode.Forbidden); Rule(r.IdempotencyKey != Guid.Empty, "REPLACEMENT_IDEMPOTENCY_KEY_REQUIRED", "Thiếu mã chống gửi trùng."); var reason = r.Reason?.Trim() ?? ""; Rule(reason.Length is >= 10 and <= 1000, "REPLACEMENT_REASON_REQUIRED", "Vui lòng nhập lý do thay Giáo viên từ 10 đến 1000 ký tự."); @@ -170,6 +172,10 @@ await uow.ExecuteInTransactionAsync(async token => return; } await uow.StudyCourses.LockCohortAsync(cohortId, token); + var invitation = await uow.StudyCohortMentorInvitations.Query() + .SingleOrDefaultAsync(x => x.Id == invitationId && x.CohortId == cohortId && x.MentorId == Actor.Id, token); + Rule(invitation is not null && invitation.Status == StudyCohortMentorInvitation.Pending, + "INVITATION_NOT_PENDING", "Lời mời đã được xử lý.", HttpStatusCode.Conflict); var currentMentorId = await uow.StudyCohorts.Query().AsNoTracking().Where(x => x.Id == cohortId).Select(x => (int?)x.MentorId).SingleOrDefaultAsync(token); Rule(currentMentorId.HasValue, "REPLACEMENT_COHORT_NOT_FOUND", "Không tìm thấy lớp.", HttpStatusCode.NotFound); // Cùng khóa lịch với luồng tạo lớp/đặt lịch để không ai chen vào lịch của hai Mentor trong lúc chuyển. @@ -187,7 +193,7 @@ await uow.ExecuteInTransactionAsync(async token => { CohortId = cohort.Id, PreviousMentorId = previousMentorId, MentorId = r.MentorId, EffectiveFromSessionNumber = e.FromSessionNumber, EffectiveFromUtc = e.Affected.Min(s => s.Availability.StartTime), - AffectedSessionCount = e.Affected.Count, Reason = reason, AssignedById = Actor.Id, IdempotencyKey = r.IdempotencyKey, + AffectedSessionCount = e.Affected.Count, Reason = reason, AssignedById = assignedByAdminId, IdempotencyKey = r.IdempotencyKey, PolicyId = e.Policy.Id == 0 ? null : e.Policy.Id, PolicyVersionSnapshot = e.Policy.Version == 0 ? null : e.Policy.Version, CreatedAtUtc = now, ImpactSnapshot = JsonSerializer.Serialize(new @@ -234,6 +240,19 @@ await uow.ExecuteInTransactionAsync(async token => } cohort.MentorId = r.MentorId; cohort.Revision++; + invitation!.Status = StudyCohortMentorInvitation.Accepted; + invitation.RespondedAtUtc = now; + invitation.Revision++; + var priorInvitations = await uow.StudyCohortMentorInvitations.Query() + .Where(x => x.CohortId == cohortId && x.MentorId == previousMentorId + && (x.Status == StudyCohortMentorInvitation.Accepted + || x.Status == StudyCohortMentorInvitation.ChangeRequested)) + .ToListAsync(token); + foreach (var prior in priorInvitations) + { + prior.Status = StudyCohortMentorInvitation.Replaced; + prior.Revision++; + } await uow.SaveChangesAsync(token); Rule(cohort.Capacity == capacityBefore && cohort.Enrollments.Select(x => x.Id).OrderBy(x => x).SequenceEqual(enrollmentIds), "REPLACEMENT_INVARIANT", "Sĩ số hoặc ghi danh bị thay đổi ngoài dự kiến.", HttpStatusCode.Conflict); @@ -242,6 +261,12 @@ await uow.ExecuteInTransactionAsync(async token => learnerIds.Select(id => (id, "Lớp học có Giáo viên mới", $"Từ buổi {e.FromSessionNumber}, {NotificationDisplayNormalizer.ClassSubject(cohort.Name, lowercasePrefix: true)} sẽ do Giáo viên mới phụ trách.", "CohortMentorReplaced", (string?)"/my-courses")) .Append((r.MentorId, "Bạn được phân công lớp mới", $"Bạn phụ trách {NotificationDisplayNormalizer.ClassSubject(cohort.Name, lowercasePrefix: true)} từ buổi {e.FromSessionNumber}.", "CohortMentorReplaced", (string?)$"/mentor/cohorts/{cohort.Id}")) .Append((previousMentorId, "Thay đổi phân công lớp", $"{NotificationDisplayNormalizer.ClassSubject(cohort.Name)} đã được chuyển cho Giáo viên khác phụ trách từ buổi {e.FromSessionNumber}.", "CohortMentorReplaced", (string?)"/mentor/cohorts"))); + var admins = await uow.UserAccounts.Query().Where(x => x.Role == Role.Admin && !x.IsDeleted) + .Select(x => x.Id).ToListAsync(token); + QueueNotifications($"cohort-mentor-invitation:{invitationId}:accepted", "StudyCohortMentorInvitation", + invitationId.ToString(), admins.Select(id => (id, "Mentor đã nhận lớp", + $"Mentor đã đồng ý dạy lớp {cohort.Name}.", "CohortMentorInvitation", + (string?)$"/admin/study-courses?cohortId={cohort.Id}&invitationId={invitationId}"))); await uow.SaveChangesAsync(token); result = new { AssignmentId = assignment.Id, CohortId = cohort.Id, assignment.MentorId, assignment.PreviousMentorId, assignment.EffectiveFromSessionNumber, assignment.AffectedSessionCount, CohortRevision = cohort.Revision, Idempotent = false }; diff --git a/RikiPath.Application/Services/StudyCohortService.cs b/RikiPath.Application/Services/StudyCohortService.cs index c08b8ed1..c93935ad 100644 --- a/RikiPath.Application/Services/StudyCohortService.cs +++ b/RikiPath.Application/Services/StudyCohortService.cs @@ -81,8 +81,7 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can await enrollmentDeadlines.ProcessAllPastCutoffCohortsAsync(ct); } var mentorFilter = filter?.MentorId; - IQueryable query = uow.StudyCohorts.Query().Include(x => x.Plan).ThenInclude(x => x.CertificateLevel).ThenInclude(x => x.CertificateType) - .Include(x => x.GroupPolicy) + IQueryable query = uow.StudyCohorts.Query().Include(x => x.GroupPolicy) .Include(x => x.Mentor).Include(x => x.Sessions).ThenInclude(x => x.Availability).ThenInclude(x => x.GroupPolicy) .Include(x => x.Enrollments).ThenInclude(e => e.Sessions) .AsSplitQuery(); @@ -91,7 +90,7 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can query = query.Include(x => x.Enrollments).ThenInclude(e => e.Learner); } query = query.Where(x => Actor.Role == Role.Admin || (Actor.Role == Role.Mentor && x.MentorId == Actor.Id) - || (Actor.Role != Role.Mentor && x.Status == "Published" && x.StartsAt > now && x.Plan.IsPublished)); + || (Actor.Role != Role.Mentor && x.Status == "Published" && x.StartsAt > now)); if (mentorFilter.HasValue) query = query.Where(x => x.MentorId == mentorFilter.Value); var rows = await query.OrderBy(x => x.StartsAt).ToListAsync(ct); var busyMentorIds = await uow.StudyCohorts.Query().AsNoTracking() @@ -105,7 +104,6 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can rows = rows.Where(x => { if (!string.Equals(x.Status, "Published", StringComparison.OrdinalIgnoreCase) - || !x.Plan.IsPublished || x.StartsAt <= now || EnrollmentCutoffUtc(x, policy) <= now) { @@ -196,7 +194,7 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can var enrolledCount = confirmedEnrolledCount + pendingHoldCount; var seatsAvailable = Math.Max(0, effectiveCapacity - enrolledCount); var isMentorView = Actor.Role == Role.Mentor; - var effectivePrice = x.TotalTuitionSnapshot is decimal snap && snap > 0 ? snap : x.Plan.Price; + var effectivePrice = x.TotalTuitionSnapshot ?? 0m; var cohortPolicy = x.GroupPolicy ?? x.Sessions.Select(s => s.Availability.GroupPolicy).FirstOrDefault(p => p is not null) ?? policy; @@ -229,7 +227,7 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can var decision = !requiresEntitlement ? new GroupEnrollmentEntitlementDecision(true, RequiresCheckout: true) : (groupEntitlementContract ?? new GroupEnrollmentEntitlementContract()) - .EvaluateGroupEnrollment(x, x.Plan, Actor.Id, null); + .EvaluateGroupEnrollment(x, Actor.Id, null); var myEnrollment = Actor.Role == Role.Learner ? x.Enrollments.FirstOrDefault(c => c.LearnerId == Actor.Id && ReservesSeat(c, now)) : null; @@ -280,7 +278,6 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can return new { x.Id, - x.PlanId, x.Name, x.MentorId, MentorName = $"{x.Mentor.FirstName} {x.Mentor.LastName}".Trim(), @@ -297,11 +294,7 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can CourseObjective = hasProposalMeta ? proposalMeta.CourseObjective : null, CourseDurationWeeks = x.CourseDurationWeeks > 0 ? x.CourseDurationWeeks - : (hasProposalMeta && proposalMeta.CourseDurationWeeks > 0 - ? proposalMeta.CourseDurationWeeks - : (x.Plan.SessionsPerWeek > 0 && x.Plan.TotalSessions is int planTotal && planTotal > 0 - ? Math.Max(1, (int)Math.Ceiling((double)planTotal / x.Plan.SessionsPerWeek)) - : 1)), + : (hasProposalMeta && proposalMeta.CourseDurationWeeks > 0 ? proposalMeta.CourseDurationWeeks : 1), CancellationReason = x.CancellationReason, CancelledAtUtc = x.CancelledAtUtc, Attachments = parsedAttachments @@ -316,12 +309,12 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can }).ToList(), x.Status, x.Revision, - Level = x.Plan.CertificateLevel.Code, - CertificateName = x.Plan.CertificateLevel.CertificateType != null ? x.Plan.CertificateLevel.CertificateType.Name : null, - x.Plan.TotalSessions, - x.Plan.SessionMinutes, - x.Plan.SessionsPerWeek, - TotalTeachingHours = TotalTeachingHoursOf(x.Plan.TotalSessions, x.Plan.SessionMinutes), + x.Level, + CertificateName = "JLPT", + TotalSessions = x.Sessions.Count, + SessionMinutes = x.Sessions.Count == 0 ? 0 : (int)(x.Sessions[0].Availability.EndTime - x.Sessions[0].Availability.StartTime).TotalMinutes, + SessionsPerWeek = SchedulePatternOf(x).Select(s => s.Weekday).Distinct().Count(), + TotalTeachingHours = Math.Round(x.Sessions.Sum(s => (s.Availability.EndTime - s.Availability.StartTime).TotalMinutes) / 60d, 1), SchedulePattern = SchedulePatternOf(x), EnrollmentClosesAtUtc = enrollmentClosesAtUtc, EnrollmentOpensAtUtc = x.EnrollmentOpensAtUtc, @@ -517,17 +510,17 @@ public Task> CohortsAsync(CohortDiscoveryFilter? filter, Can public Task> SaveCohortAsync(int? id, SaveStudyCohort r, CancellationToken ct) => Run(() => { Admin(); - // Lớp học nhóm chỉ được tạo & công bố tự động khi phê duyệt đề xuất mở lớp; mọi điều chỉnh sau duyệt đi qua luồng chuyên biệt. + // Creation goes through the Admin invitation flow; published schedules use dedicated change workflows. if (!id.HasValue) { Rule(false, "LEGACY_MANUAL_COHORT_DISABLED", - "Lớp học nhóm được tạo và mở tuyển sinh tự động khi phê duyệt đề xuất mở lớp; không hỗ trợ tạo lớp thủ công.", + "Hãy dùng trang Tạo lịch & lớp học để tạo lớp và mời Giáo viên.", HttpStatusCode.Conflict); } else { Rule(false, "COHORT_SCHEDULE_LOCKED_BY_PROPOSAL", - "Không thể chỉnh sửa trực tiếp gói học, giáo viên, sĩ số, lịch đã duyệt hoặc trạng thái mở lớp. Vui lòng sử dụng quy trình dời lịch, đổi giáo viên hoặc hủy lớp chuyên biệt.", + "Không thể chỉnh sửa trực tiếp lớp đã tạo. Vui lòng sử dụng quy trình dời lịch, đổi giáo viên hoặc hủy lớp chuyên biệt.", HttpStatusCode.Conflict); } @@ -559,8 +552,8 @@ private static bool MatchesDiscoveryFilter(StudyCohort x, CohortDiscoveryFilter { if (f.MentorId.HasValue && x.MentorId != f.MentorId.Value) return false; if (!string.IsNullOrWhiteSpace(f.Level) - && !string.Equals(x.Plan.CertificateLevel?.Code, f.Level.Trim(), StringComparison.OrdinalIgnoreCase)) return false; - if (f.SessionsPerWeek.HasValue && x.Plan.SessionsPerWeek != f.SessionsPerWeek.Value) return false; + && !string.Equals(x.Level, f.Level.Trim(), StringComparison.OrdinalIgnoreCase)) return false; + if (f.SessionsPerWeek.HasValue && SchedulePatternOf(x).Select(s => s.Weekday).Distinct().Count() != f.SessionsPerWeek.Value) return false; if (f.Weekday.HasValue || f.FromTime.HasValue || f.ToTime.HasValue) { // Có ít nhất một buổi (giờ Việt Nam) đúng thứ được lọc và bắt đầu trong khung giờ [fromTime, toTime]. diff --git a/RikiPath.Application/Services/StudyCohortTransferService.cs b/RikiPath.Application/Services/StudyCohortTransferService.cs index 7f1801b0..d01e56db 100644 --- a/RikiPath.Application/Services/StudyCohortTransferService.cs +++ b/RikiPath.Application/Services/StudyCohortTransferService.cs @@ -73,7 +73,6 @@ private static bool SourceStarted(StudyCohort sourceCohort, DateTime now) => (FirstSessionStartUtc(sourceCohort) ?? sourceCohort.StartsAt) <= now; private IQueryable CohortForTransfer =>uow.StudyCohorts.Query() - .Include(x => x.Plan).ThenInclude(x => x.CertificateLevel) .Include(x => x.Mentor) .Include(x => x.Sessions).ThenInclude(x => x.Availability).ThenInclude(x => x.GroupPolicy) .Include(x => x.Enrollments).AsSplitQuery(); @@ -116,21 +115,18 @@ void Check(string code, bool passed, string message, HttpStatusCode status = Htt "Lớp đích đã bắt đầu; chưa hỗ trợ chuyển vào lớp đang học."); Check("TRANSFER_TARGET_CUTOFF", EnrollmentCutoffUtc(target) > now, "Lớp đích đã qua hạn khóa đăng ký theo chính sách."); - Check("TRANSFER_LEVEL_MISMATCH", target.Plan.CertificateLevelId == source.CertificateLevelId, + Check("TRANSFER_LEVEL_MISMATCH", string.Equals(target.Level, sourceCohort.Level, StringComparison.OrdinalIgnoreCase), "Lớp đích khác cấp độ JLPT của khóa đã mua."); - Check("TRANSFER_CURRICULUM_MISMATCH", target.Plan.SessionType == "Group" - && target.Plan.TotalSessions == source.TotalSessions && target.Plan.SessionMinutes == source.SessionMinutes - && target.Sessions.Count == target.Plan.TotalSessions, + Check("TRANSFER_CURRICULUM_MISMATCH", target.Sessions.Count == source.TotalSessions + && target.Sessions.All(s => (s.Availability.EndTime - s.Availability.StartTime).TotalMinutes == source.SessionMinutes), "Lớp đích khác chương trình (số buổi/thời lượng) của khóa đã mua."); var sourcePlanPrice = await uow.StudyCoursePlans.Query().Where(p => p.Id == source.PlanId) .Select(p => (decimal?)p.Price).SingleOrDefaultAsync(ct); var effectiveSourceTuition = sourceCohort.TotalTuitionSnapshot is decimal srcSnap && srcSnap > 0 ? srcSnap : (source.Amount > 0 ? source.Amount : (sourcePlanPrice ?? 0m)); - var effectiveTargetTuition = target.TotalTuitionSnapshot is decimal dstSnap && dstSnap > 0 - ? dstSnap - : target.Plan.Price; - Check("TRANSFER_PAYMENT_POLICY_REQUIRED", target.PlanId == source.PlanId || effectiveTargetTuition == effectiveSourceTuition, + var effectiveTargetTuition = target.TotalTuitionSnapshot ?? 0m; + Check("TRANSFER_PAYMENT_POLICY_REQUIRED", effectiveTargetTuition == effectiveSourceTuition, "Lớp đích có học phí khác; chưa có chính sách thu thêm/hoàn tiền nên không thể chuyển."); Check("TRANSFER_TARGET_SCHEDULE_PENDING", target.Sessions.All(s => s.Availability.IsApproved && !s.Availability.IsDeleted && s.Availability.RejectedAt == null && s.Availability.ChangeRequestedAt == null), @@ -151,7 +147,7 @@ void Check(string code, bool passed, string message, HttpStatusCode status = Htt private static object TransferCohortSummary(StudyCohort c, DateTime now) => new { c.Id, c.Name, c.Status, c.MentorId, MentorName = $"{c.Mentor?.FirstName} {c.Mentor?.LastName}".Trim(), - Level = c.Plan?.CertificateLevel?.Code, c.PlanId, c.StartsAt, c.EndsAt, + c.Level, c.StartsAt, c.EndsAt, Capacity = c.CapacitySnapshot ?? c.Capacity, EnrolledCount = c.Enrollments.Count(x => ReservesSeat(x, now)), SeatsAvailable = Math.Max(0, (c.CapacitySnapshot ?? c.Capacity) - c.Enrollments.Count(x => ReservesSeat(x, now))), @@ -215,12 +211,13 @@ await uow.ExecuteInTransactionAsync(async token => if (targetCohortId.HasValue) { var sourceCohortId = locked.CohortId!.Value; - var target = await uow.StudyCohorts.Query().Include(x => x.Plan).Include(x => x.Sessions).ThenInclude(x => x.Availability) + var target = await uow.StudyCohorts.Query().Include(x => x.Sessions).ThenInclude(x => x.Availability) .SingleOrDefaultAsync(x => x.Id == targetCohortId.Value, token); Rule(target is not null, "TRANSFER_TARGET_NOT_FOUND", "Không tìm thấy lớp đích.", HttpStatusCode.NotFound); Rule(target!.Id != sourceCohortId, "TRANSFER_TARGET_SAME_COHORT", "Lớp đích phải khác lớp hiện tại."); Rule(target.Status == "Published", "TRANSFER_TARGET_NOT_PUBLISHED", "Lớp đích chưa mở đăng ký."); - Rule(target.Plan.CertificateLevelId == locked.CertificateLevelId, "TRANSFER_LEVEL_MISMATCH", "Lớp đích khác cấp độ JLPT của khóa đã mua."); + Rule(await uow.CertificateLevels.Query().AnyAsync(level => level.Id == locked.CertificateLevelId && level.Code == target.Level, token), + "TRANSFER_LEVEL_MISMATCH", "Lớp đích khác cấp độ JLPT của khóa đã mua."); Rule((FirstSessionStartUtc(target) ?? target.StartsAt) > DateTime.UtcNow, "TRANSFER_TARGET_STARTED", "Lớp đích đã bắt đầu; chưa hỗ trợ chuyển vào lớp đang học."); } @@ -284,7 +281,7 @@ public Task> TransferRequestDetailAsync(int requestId, Cance var assignments = await uow.HomeworkAssignments.Query().AsNoTracking().Include(h => h.Submission) .Where(h => !h.IsDeleted && h.StudyCourseId == source.Id).ToListAsync(ct); var candidates = await CohortForTransfer.AsNoTracking() - .Where(x => x.Id != sourceCohort.Id && x.Status == "Published" && x.Plan.CertificateLevelId == source.CertificateLevelId) + .Where(x => x.Id != sourceCohort.Id && x.Status == "Published" && x.Level == sourceCohort.Level) .ToListAsync(ct); var targetId = request!.TargetCohortId ?? request.RequestedTargetCohortId; var evaluation = request.Status == CohortTransferRequest.Pending @@ -383,11 +380,13 @@ await uow.ExecuteInTransactionAsync(async token => var destination = new StudyCourse { CohortId = target.Id, MentorId = target.MentorId, StartsAt = target.StartsAt, EndsAt = target.EndsAt, - SessionType = "Group", TargetExamDate = target.Plan.TargetExamDate, LearnerId = source.LearnerId, - PurchaseKey = Guid.NewGuid(), PlanId = target.PlanId, Name = target.Plan.Name, - CertificateLevelId = target.Plan.CertificateLevelId, PlanRevision = target.Plan.Revision, - DurationMonths = target.Plan.DurationMonths, SessionsPerWeek = target.Plan.SessionsPerWeek, - TotalSessions = target.Plan.TotalSessions!.Value, SessionMinutes = target.Plan.SessionMinutes!.Value, + SessionType = "Group", LearnerId = source.LearnerId, + PurchaseKey = Guid.NewGuid(), Name = target.Name, + CertificateLevelId = source.CertificateLevelId, + DurationMonths = Math.Max(1, (int)Math.Ceiling(target.CourseDurationWeeks / 4d)), + SessionsPerWeek = target.Sessions.Select(s => s.Availability.StartTime.DayOfWeek).Distinct().Count(), + TotalSessions = target.Sessions.Count, + SessionMinutes = (int)(target.Sessions[0].Availability.EndTime - target.Sessions[0].Availability.StartTime).TotalMinutes, // Giữ nguyên điều kiện quyền lợi đã đóng băng khi mua ở ghi danh nguồn. RetakeClaimDays = source.RetakeClaimDays, MinimumHomeworkPercent = source.MinimumHomeworkPercent, MaximumAbsencePercent = source.MaximumAbsencePercent, diff --git a/RikiPath.Application/Services/StudyCourseChangeService.cs b/RikiPath.Application/Services/StudyCourseChangeService.cs index 9bab7f1d..9411569f 100644 --- a/RikiPath.Application/Services/StudyCourseChangeService.cs +++ b/RikiPath.Application/Services/StudyCourseChangeService.cs @@ -18,6 +18,8 @@ await uow.CourseScheduleRequests.Query().Where(x => Actor.Role == Role.Admin public Task> RequestChangeAsync(int id, RequestCourseChange r, CancellationToken ct) => Change(id, async c => { Active(c); + Require(!c.CohortId.HasValue || Actor.Role == Role.Admin, + "Với lớp nhóm, Mentor gửi yêu cầu đổi người dạy; Học viên gửi yêu cầu chuyển lớp để Admin duyệt."); Require(r.Kind is "Cancel" or "Move" && !string.IsNullOrWhiteSpace(r.Reason) && r.Reason.Length <= 1000, "Chọn hủy/dời và nhập lý do."); var s = c.Sessions.SingleOrDefault(x => x.Id == r.SessionId); var now = DateTime.UtcNow; diff --git a/RikiPath.Application/Services/StudyCourseService.cs b/RikiPath.Application/Services/StudyCourseService.cs index 9c97ee1d..d331c08c 100644 --- a/RikiPath.Application/Services/StudyCourseService.cs +++ b/RikiPath.Application/Services/StudyCourseService.cs @@ -161,6 +161,8 @@ private async Task TryVoidPaymentLinkBestEffortAsync(long orderCode, string reas .Include(x => x.Sessions).Include(x => x.Homework).Include(x => x.RetakeRequests).Include(x => x.Audit).AsSplitQuery(); private void Audit(StudyCourse c, string action, string detail) => c.Audit.Add(new() { ActorId = Actor.Id, Action = action, Detail = detail }); + private static void AuditVerifiedPayment(StudyCourse c, string action, string detail) + => c.Audit.Add(new() { ActorId = 0, Action = action, Detail = detail }); private static void Active(StudyCourse c) => Require(c.Status == "Active" && c.PaymentStatus is "Paid" or "PartiallyRefunded", "Khóa chưa hoạt động hoặc đã chốt dữ liệu."); private async Task> Run(Func> action) @@ -225,10 +227,11 @@ await uow.CertificateLevels.Query().Include(x => x.CertificateType) public Task> PlansAsync(CancellationToken ct) => Run(async () => { + if (Actor.Role != Role.Admin) return (object)new List(); var policy = await EffectiveGroupPolicyAsync(DateTime.UtcNow, ct); _ = policy; var rows = await uow.StudyCoursePlans.Query().Include(x => x.CertificateLevel) - .Where(x => Actor.Role == Role.Admin || (x.IsPublished && !x.CertificateLevel.IsDeleted && !x.CertificateLevel.CertificateType.IsDeleted && x.CertificateLevel.CertificateType.IsActive)) + .Where(x => !x.CertificateLevel.IsDeleted && !x.CertificateLevel.CertificateType.IsDeleted) .OrderBy(x => x.Id).Select(x => new { x.Id, x.Name, x.CertificateLevelId, Level = x.CertificateLevel.Code, x.DurationMonths, x.SessionsPerWeek, x.SessionMinutes, x.TotalSessions, x.RetakeClaimDays, x.Price, x.IsPublished, x.Revision, x.SessionType, x.Capacity, x.TargetExamDate }).ToListAsync(ct); @@ -266,9 +269,9 @@ private async Task EffectiveGroupPolicyAsync(DateTime atUtc, public Task> SavePlanAsync(int? id, SaveCoursePlan r, CancellationToken ct) => Run(() => { Admin(); - // Gói lớp nhóm chỉ được hệ thống khởi tạo/khớp tự động theo chính sách Học phí & tuyển sinh khi duyệt đề xuất mở lớp. + // Keep historical plans readable for Admin; new classes are created directly. Rule(false, "LEGACY_MANUAL_COURSE_PLAN_DISABLED", - "Gói lớp học nhóm được hệ thống tự động tạo theo chính sách Học phí & tuyển sinh khi phê duyệt đề xuất mở lớp; không hỗ trợ tạo hoặc chỉnh sửa gói lớp nhóm thủ công.", + "Lớp học mới được tạo trực tiếp theo lịch và học phí do Quản trị viên nhập; không còn tạo gói lớp nhóm.", HttpStatusCode.Conflict); return Task.FromResult(new { Id = id ?? 0 }); }); @@ -393,7 +396,6 @@ private async Task> LoadCohortLifecycleMeta return new Dictionary(); var cohorts = await uow.StudyCohorts.Query().AsNoTracking() - .Include(x => x.Plan) .Include(x => x.GroupPolicy) .Include(x => x.Enrollments).ThenInclude(e => e.Sessions) .Include(x => x.Sessions).ThenInclude(s => s.Availability).ThenInclude(a => a.GroupPolicy) @@ -466,9 +468,7 @@ private async Task> LoadCohortLifecycleMeta && proposalWeeksById.TryGetValue(x.SourceProposalId.Value, out var pw) && pw > 0 ? pw - : (x.Plan?.SessionsPerWeek > 0 && x.Plan.TotalSessions is int pts && pts > 0 - ? Math.Max(1, (int)Math.Ceiling((double)pts / x.Plan.SessionsPerWeek)) - : 1)); + : 1); result[x.Id] = new CohortLifecycleMeta( CohortStatus: x.Status, @@ -570,13 +570,9 @@ public async Task> EnrollCohortAsync(int cohortId, EnrollCoh { await enrollmentDeadlines.ProcessCohortIfPastCutoffAsync(cohortId, ct); } - var planId = await uow.StudyCohorts.Query() - .Where(x => x.Id == cohortId) - .Select(x => (int?)x.PlanId) - .SingleOrDefaultAsync(ct); - if (!planId.HasValue) + if (!await uow.StudyCohorts.Query().AnyAsync(x => x.Id == cohortId, ct)) return ApiResponse.Fail("Không tìm thấy lớp học.", HttpStatusCode.NotFound); - return await PurchaseAsync(new PurchaseCourse(planId.Value, r.IdempotencyKey, cohortId, r.EntitlementReference), ct); + return await PurchaseAsync(new PurchaseCourse(null, r.IdempotencyKey, cohortId, r.EntitlementReference), ct); } public Task> PurchaseAsync(PurchaseCourse r, CancellationToken ct) => Run(async () => @@ -592,17 +588,24 @@ await uow.ExecuteInTransactionAsync(async token => course = await uow.StudyCourses.Query().SingleOrDefaultAsync(x => x.LearnerId == Actor.Id && x.PurchaseKey == r.IdempotencyKey, token); if (course is not null) { - RequireConflict(course.PlanId == r.PlanId && course.CohortId == r.CohortId, "Mã giao dịch đã dùng cho gói khác."); + RequireConflict(course.CohortId == r.CohortId, "Mã giao dịch đã dùng cho lớp khác."); entitlementMode = new GroupEnrollmentEntitlementDecision(true, RequiresCheckout: course.PaymentStatus == "Pending"); return; } - var p = await uow.StudyCoursePlans.GetByIdAsync(r.PlanId, token); - Require(p is { IsPublished: true, SessionMinutes: not null, TotalSessions: not null } && p.Price > 0, "Gói chưa đủ cấu hình để mua."); - Rule(p!.SessionType == "Group" && r.CohortId.HasValue, "INDIVIDUAL_COURSE_DISCONTINUED", "Khóa học cá nhân 1-1 đã ngừng hỗ trợ. Vui lòng chọn lớp học nhóm.", HttpStatusCode.Conflict); - Require(!p!.TargetExamDate.HasValue || p.TargetExamDate > DateTime.UtcNow, "Gói đã qua kỳ thi mục tiêu."); - Require(await uow.CertificateLevels.Query().AnyAsync(x => x.Id == p!.CertificateLevelId && !x.IsDeleted - && !x.CertificateType.IsDeleted && x.CertificateType.IsActive, token), "Cấp độ không còn mở đăng ký."); - StudyCohort? cohort = null; + Rule(r.CohortId.HasValue, "COHORT_REQUIRED", "Chọn lớp học để đăng ký.", HttpStatusCode.Conflict); + await uow.StudyCourses.LockScheduleAsync(Actor.Id, Actor.Id, token); + await uow.StudyCourses.LockCohortAsync(r.CohortId!.Value, token); + var cohort = await uow.StudyCohorts.Query() + .Include(x => x.GroupPolicy) + .Include(x => x.Sessions).ThenInclude(x => x.Availability).ThenInclude(x => x.GroupPolicy) + .Include(x => x.Enrollments).SingleOrDefaultAsync(x => x.Id == r.CohortId.Value, token); + var now = DateTime.UtcNow; + const string closedMessage = "Lớp học đã đóng tuyển sinh hoặc đã được hủy."; + Rule(cohort is not null && cohort.Status == "Published", "COHORT_ENROLLMENT_CLOSED", closedMessage, HttpStatusCode.Conflict); + var level = await uow.CertificateLevels.Query().AsNoTracking() + .Where(x => x.Code == cohort!.Level && !x.IsDeleted && !x.CertificateType.IsDeleted && x.CertificateType.IsActive) + .Select(x => new { x.Id }).FirstOrDefaultAsync(token); + Rule(level is not null, "COHORT_LEVEL_INVALID", "Cấp độ lớp không còn mở đăng ký.", HttpStatusCode.Conflict); int? cohortPolicyId = null; int? cohortPolicyVersion = null; int? cohortCapacitySnapshot = null; @@ -610,25 +613,14 @@ await uow.ExecuteInTransactionAsync(async token => // Thời gian giữ chỗ do Admin cấu hình trong chính sách hiện hành (mặc định 10 phút). var holdPolicy = groupPolicies is null ? null : await groupPolicies.GetEffectiveAsync(DateTime.UtcNow, token); var holdMinutes = holdPolicy?.CheckoutHoldMinutes is int configuredHold and > 0 ? configuredHold : 10; - if (p!.SessionType == "Group") + if (cohort is not null) { - Require(r.CohortId.HasValue, "Chọn lớp có lịch cố định."); - await uow.StudyCourses.LockScheduleAsync(Actor.Id, Actor.Id, token); - await uow.StudyCourses.LockCohortAsync(r.CohortId!.Value, token); - cohort = await uow.StudyCohorts.Query() - .Include(x => x.GroupPolicy) - .Include(x => x.Sessions).ThenInclude(x => x.Availability).ThenInclude(x => x.GroupPolicy) - .Include(x => x.Enrollments).SingleOrDefaultAsync(x => x.Id == r.CohortId.Value, token); - var now = DateTime.UtcNow; - const string closedMessage = "Lớp học đã đóng tuyển sinh hoặc đã được hủy."; - Rule(cohort is not null && cohort.PlanId == p.Id && cohort.Status == "Published", - "COHORT_ENROLLMENT_CLOSED", closedMessage, HttpStatusCode.Conflict); Rule(EnrollmentCutoffUtc(cohort!, holdPolicy) > now, "COHORT_ENROLLMENT_CLOSED", closedMessage, HttpStatusCode.Conflict); Rule(!cohort!.Sessions.Any() || cohort.Sessions.Min(s => s.Availability.StartTime) > now, "COHORT_ENROLLMENT_CLOSED", closedMessage, HttpStatusCode.Conflict); // Bấm lặp (mã giao dịch mới) khi đơn cũ còn hạn: trả lại đơn đang chờ, không tạo checkout trùng. var resumable = cohort.Enrollments - .Where(x => x.LearnerId == Actor.Id && x.PlanId == p.Id && x.PaymentStatus == "Pending" && x.PaymentExpiresAt > now) + .Where(x => x.LearnerId == Actor.Id && x.PaymentStatus == "Pending" && x.PaymentExpiresAt > now) .OrderByDescending(x => x.Id).FirstOrDefault(); if (resumable is not null) { @@ -641,7 +633,7 @@ await uow.ExecuteInTransactionAsync(async token => if (policySlots.Count > 0) { var decision = (groupEntitlementContract ?? new GroupEnrollmentEntitlementContract()) - .EvaluateGroupEnrollment(cohort, p, Actor.Id, r.EntitlementReference); + .EvaluateGroupEnrollment(cohort, Actor.Id, r.EntitlementReference); if (!string.IsNullOrWhiteSpace(r.EntitlementReference)) Rule(decision.IsAuthorized, "COHORT_ENTITLEMENT_INVALID", decision.ErrorMessage ?? "Mã quyền ghi danh lớp nhóm không hợp lệ.", HttpStatusCode.Conflict); @@ -675,8 +667,8 @@ await uow.ExecuteInTransactionAsync(async token => Rule(false, "COHORT_FULL", "Tất cả chỗ còn lại đang được giữ chờ thanh toán. Vui lòng thử lại sau ít phút.", HttpStatusCode.Conflict); Rule(!cohort.Enrollments.Any(x => x.LearnerId == Actor.Id && ReservesSeat(x, now)), "COHORT_ALREADY_ENROLLED", "Bạn đã đăng ký hoặc đang giữ chỗ lớp này.", HttpStatusCode.Conflict); - Rule(cohort.Sessions.Count == p.TotalSessions && cohort.Sessions.All(s => (s.Availability.EndTime - s.Availability.StartTime).TotalMinutes == p.SessionMinutes), - "COHORT_PLAN_CHANGED", "Gói học đã thay đổi; Quản trị viên cần kiểm tra lại lớp.", HttpStatusCode.Conflict); + Rule(cohort.Sessions.Count > 0 && cohort.Sessions.All(s => s.Availability.EndTime > s.Availability.StartTime), + "COHORT_SCHEDULE_INVALID", "Lịch lớp không hợp lệ; Quản trị viên cần kiểm tra lại lớp.", HttpStatusCode.Conflict); Rule(!await HasLearnerConflictAsync(Actor.Id, cohort.Sessions.Select(s => s.Availability).ToList(), 0, token), "COHORT_SCHEDULE_CONFLICT", "Bạn đã có lịch hoặc đang giữ chỗ trùng giờ.", HttpStatusCode.Conflict); if (entitlementMode.RequiresCheckout) @@ -689,17 +681,18 @@ await uow.ExecuteInTransactionAsync(async token => checkoutExpiresAt = hold < cutoff ? hold : cutoff; } } - else Require(!r.CohortId.HasValue, "Gói 1–1 không đăng ký vào lớp nhóm."); var grantDirectEntitlement = cohort is not null && !entitlementMode.RequiresCheckout; - var authoritativePrice = cohort?.TotalTuitionSnapshot is decimal snapshotTotal && snapshotTotal > 0 - ? snapshotTotal - : p.Price; + var authoritativePrice = cohort?.TotalTuitionSnapshot ?? 0m; Require(authoritativePrice > 0 || grantDirectEntitlement, "Học phí lớp học chưa được cấu hình hợp lệ."); + var orderedSessions = cohort!.Sessions.OrderBy(s => s.Number).ToList(); + var sessionMinutes = (int)(orderedSessions[0].Availability.EndTime - orderedSessions[0].Availability.StartTime).TotalMinutes; + var sessionsPerWeek = SchedulePatternOf(cohort).Select(s => s.Weekday).Distinct().Count(); course = new StudyCourse { CohortId = cohort?.Id, MentorId = cohort?.MentorId, StartsAt = cohort?.StartsAt, EndsAt = cohort?.EndsAt, - SessionType = p.SessionType, TargetExamDate = p.TargetExamDate, LearnerId = Actor.Id, PurchaseKey = r.IdempotencyKey, - PlanId = p!.Id, Name = cohort?.Name ?? p.Name, CertificateLevelId = p.CertificateLevelId, PlanRevision = p.Revision, - DurationMonths = p.DurationMonths, SessionsPerWeek = p.SessionsPerWeek, TotalSessions = p.TotalSessions!.Value, - SessionMinutes = p.SessionMinutes!.Value, RetakeClaimDays = p.RetakeClaimDays, + SessionType = "Group", LearnerId = Actor.Id, PurchaseKey = r.IdempotencyKey, + Name = cohort.Name, CertificateLevelId = level!.Id, + DurationMonths = Math.Max(1, (int)Math.Ceiling(cohort.CourseDurationWeeks / 4d)), + SessionsPerWeek = sessionsPerWeek, TotalSessions = orderedSessions.Count, + SessionMinutes = sessionMinutes, GroupPolicyId = cohortPolicyId ?? cohort?.GroupPolicyId, PolicyVersionSnapshot = cohortPolicyVersion ?? cohort?.PolicyVersionSnapshot, CapacitySnapshot = cohortCapacitySnapshot, @@ -709,7 +702,7 @@ await uow.ExecuteInTransactionAsync(async token => Status = grantDirectEntitlement ? "Active" : "PendingPayment", PaymentReference = entitlementMode.EntitlementReference, PaymentExpiresAt = grantDirectEntitlement ? null : checkoutExpiresAt ?? DateTime.UtcNow.AddMinutes(holdMinutes), - OrderSnapshot = cohort is null ? null : CohortOrderSnapshot(cohort, p, authoritativePrice, cohortPolicyId, cohortPolicyVersion, + OrderSnapshot = CohortOrderSnapshot(cohort, authoritativePrice, cohortPolicyId, cohortPolicyVersion, grantDirectEntitlement ? "AdminEntitlement" : "PayOS", grantDirectEntitlement ? null : holdMinutes) }; if (grantDirectEntitlement && cohort is not null) AddCohortSessions(course, cohort); @@ -718,7 +711,7 @@ await uow.ExecuteInTransactionAsync(async token => Audit(course, grantDirectEntitlement ? "CohortEnrolled" : "PurchaseCreated", grantDirectEntitlement ? $"Ghi danh lớp #{cohort!.Id} theo quyền học được duyệt ({entitlementMode.EntitlementReference ?? "entitlement"})." - : $"Đã lưu thông tin gói học. Quyền học lại một lần xét minh chứng nộp bài tập về nhà đúng hạn ({retakeThresholdOp} {retakeThresholdPct:0.##}%); không xét tỷ lệ nghỉ."); + : $"Đã tạo đơn ghi danh lớp #{cohort!.Id} theo học phí Admin đã đặt. Quyền học lại một lần xét minh chứng nộp bài tập về nhà đúng hạn ({retakeThresholdOp} {retakeThresholdPct:0.##}%); không xét tỷ lệ nghỉ."); await uow.StudyCourses.AddAsync(course, token); await uow.SaveChangesAsync(token); if (grantDirectEntitlement && cohort is not null && !string.IsNullOrWhiteSpace(entitlementMode.EntitlementReference) @@ -778,7 +771,7 @@ await uow.ExecuteInTransactionAsync(async token => }); // Điều khoản đơn hàng bất biến chụp tại thời điểm checkout (giá, lịch, sức chứa, phiên bản chính sách). - private static string CohortOrderSnapshot(StudyCohort cohort, StudyCoursePlan plan, decimal authoritativePrice, int? policyId, int? policyVersion, string checkoutKind, + private static string CohortOrderSnapshot(StudyCohort cohort, decimal authoritativePrice, int? policyId, int? policyVersion, string checkoutKind, int? holdMinutes = null) { var hasSessions = cohort.Sessions.Count > 0; @@ -787,14 +780,13 @@ private static string CohortOrderSnapshot(StudyCohort cohort, StudyCoursePlan pl cohortId = cohort.Id, cohortRevision = cohort.Revision, cohortName = cohort.Name, - planId = plan.Id, - planRevision = plan.Revision, + level = cohort.Level, price = authoritativePrice, tuitionPerSessionSnapshot = cohort.TuitionPerSessionSnapshot, tuitionPolicyVersionSnapshot = cohort.TuitionPolicyVersionSnapshot, currency = "VND", - totalSessions = plan.TotalSessions, - sessionMinutes = plan.SessionMinutes, + totalSessions = cohort.Sessions.Count, + sessionMinutes = cohort.Sessions.Count == 0 ? 0 : (int)(cohort.Sessions[0].Availability.EndTime - cohort.Sessions[0].Availability.StartTime).TotalMinutes, firstSessionUtc = hasSessions ? cohort.Sessions.Min(s => s.Availability.StartTime) : cohort.StartsAt, lastSessionUtc = hasSessions ? cohort.Sessions.Max(s => s.Availability.EndTime) : cohort.EndsAt, enrollmentCutoffUtc = EnrollmentCutoffUtc(cohort), @@ -924,6 +916,16 @@ public async Task> ConfirmPaymentAsync(int courseId, Payment callback.OrderCode, reference, "PayOSWebhook", ct)); } + public Task> ConfirmVerifiedPaymentStatusAsync(int courseId, PaymentLinkInformation info, CancellationToken ct) + { + if (!string.Equals(info.Status?.Trim(), "PAID", StringComparison.OrdinalIgnoreCase) + || info.AmountPaid < info.Amount) + return Task.FromResult(ApiResponse.Fail("PayOS chưa xác nhận đủ tiền cho đơn này.", HttpStatusCode.Conflict)); + + return Run(() => ApplyVerifiedCoursePaymentAsync(courseId, true, info.Amount, + info.OrderCode, info.PaymentLinkId, "PayOSStatusQuery", ct)); + } + // Lõi xử lý thanh toán ĐÃ XÁC MINH (webhook có chữ ký hợp lệ hoặc truy vấn trạng thái server-to-server). // Toàn bộ cấp quyền + ghi danh nằm trong một giao dịch: lỗi ở bất kỳ bước nào sẽ hoàn tác cả hai. private async Task ApplyVerifiedCoursePaymentAsync(int courseId, bool isSuccess, decimal amount, long orderCode, @@ -953,7 +955,7 @@ await uow.ExecuteInTransactionAsync(async token => if (c.PaymentStatus == "Pending") { c.PaymentStatus = "Failed"; c.Status = "PaymentFailed"; c.PaymentExpiresAt = now; - Audit(c, "PaymentFailed", $"Cổng thanh toán báo giao dịch không thành công ({source}); giải phóng giữ chỗ."); + AuditVerifiedPayment(c, "PaymentFailed", $"Cổng thanh toán báo giao dịch không thành công ({source}); giải phóng giữ chỗ."); await uow.SaveChangesAsync(token); } result = new { Confirmed = false, Idempotent = false, c.PaymentStatus, c.Status }; @@ -973,7 +975,7 @@ await uow.ExecuteInTransactionAsync(async token => c.Status = "PaymentReview"; c.PaymentReviewReason = "LATE_PAYMENT_AFTER_CANCEL_OR_FAILURE"; enteredPaymentReview = true; - Audit(c, "CancelledEnrollmentPaidLate", $"Đã nhận thanh toán sau khi đơn bị hủy/thất bại/hết hạn ({source}); Quản trị viên sẽ xem xét xử lý, không tự kích hoạt quyền học."); + AuditVerifiedPayment(c, "CancelledEnrollmentPaidLate", $"Đã nhận thanh toán sau khi đơn bị hủy/thất bại/hết hạn ({source}); Quản trị viên sẽ xem xét xử lý, không tự kích hoạt quyền học."); await QueuePaymentReviewNotificationsAsync(c, token); await uow.SaveChangesAsync(token); result = new { Confirmed = true, Idempotent = false, c.Status, c.PaymentReviewReason }; @@ -986,7 +988,6 @@ await uow.ExecuteInTransactionAsync(async token => await uow.StudyCourses.LockCohortAsync(c.CohortId.Value, token); var cohort = await uow.StudyCohorts.Query() .Include(x => x.GroupPolicy) - .Include(x => x.Plan) .Include(x => x.Enrollments) .Include(x => x.Sessions).ThenInclude(x => x.Availability).ThenInclude(x => x.GroupPolicy) .SingleAsync(x => x.Id == c.CohortId.Value, token); @@ -1009,7 +1010,7 @@ await uow.ExecuteInTransactionAsync(async token => c.Status = "PaymentReview"; c.PaymentReviewReason = reviewReason; enteredPaymentReview = true; - Audit(c, "PaidEnrollmentUnresolved", + AuditVerifiedPayment(c, "PaidEnrollmentUnresolved", "Đã nhận thanh toán nhưng suất học không còn hợp lệ; chuyển Quản trị viên xem xét hoàn tiền hoặc chuyển lớp."); await QueuePaymentReviewNotificationsAsync(c, token); } @@ -1022,7 +1023,7 @@ await uow.ExecuteInTransactionAsync(async token => await uow.CohortEnrollmentEntitlements.AddAsync(new CohortEnrollmentEntitlement { StudyCohortId = cohort.Id, - PlanId = cohort.PlanId, + PlanId = c.PlanId, LearnerId = c.LearnerId, SourceType = "VerifiedCoursePurchase", EntitlementReference = $"PURCHASE-{c.Id}", @@ -1034,7 +1035,7 @@ await uow.CohortEnrollmentEntitlements.AddAsync(new CohortEnrollmentEntitlement }, token); } AddCohortSessions(c, cohort); - Audit(c, "CohortPurchaseConfirmed", + AuditVerifiedPayment(c, "CohortPurchaseConfirmed", $"Xác nhận thanh toán đơn PayOS {orderCode} ({source}); ghi danh lớp \"{cohort.Name}\" và cấp quyền PURCHASE-{c.Id}."); var learnerInfo = await uow.UserAccounts.Query().AsNoTracking() @@ -1468,16 +1469,18 @@ public Task> ReviewRetakeAsync(int id, int requestId, Review { Require(r.CohortId.HasValue, "Chọn lớp đợt kế tiếp cho gói học lại nhóm."); await uow.StudyCourses.LockCohortAsync(r.CohortId!.Value, ct); - var cohort = await uow.StudyCohorts.Query().Include(x => x.Plan).Include(x => x.Enrollments) + var cohort = await uow.StudyCohorts.Query().Include(x => x.Enrollments) .Include(x => x.Sessions).ThenInclude(x => x.Availability).SingleOrDefaultAsync(x => x.Id == r.CohortId.Value, ct); Require(cohort is not null && cohort.Status == "Published" && cohort.StartsAt > DateTime.UtcNow - && cohort.Plan.CertificateLevelId == c.CertificateLevelId && cohort.Plan.TotalSessions >= c.TotalSessions - && cohort.Plan.SessionMinutes >= c.SessionMinutes + && await uow.CertificateLevels.Query().AnyAsync(level => level.Id == c.CertificateLevelId && level.Code == cohort.Level, ct) + && cohort.Sessions.Count >= c.TotalSessions + && cohort.Sessions.All(s => (s.Availability.EndTime - s.Availability.StartTime).TotalMinutes >= c.SessionMinutes) && cohort.Enrollments.Count(x => ReservesSeat(x, DateTime.UtcNow)) < (cohort.CapacitySnapshot ?? cohort.Capacity), "Lớp học lại phải còn chỗ, cùng cấp độ, đủ số buổi/thời lượng tương đương và chưa bắt đầu."); - retake.CohortId = cohort!.Id; retake.PlanId = cohort.PlanId; retake.MentorId = cohort.MentorId; + retake.CohortId = cohort!.Id; retake.PlanId = null; retake.MentorId = cohort.MentorId; retake.StartsAt = cohort.StartsAt; retake.EndsAt = cohort.EndsAt; retake.CapacitySnapshot = cohort.CapacitySnapshot ?? cohort.Capacity; - retake.TotalSessions = cohort.Sessions.Count; retake.SessionMinutes = cohort.Plan.SessionMinutes!.Value; + retake.TotalSessions = cohort.Sessions.Count; + retake.SessionMinutes = (int)(cohort.Sessions[0].Availability.EndTime - cohort.Sessions[0].Availability.StartTime).TotalMinutes; AddCohortSessions(retake, cohort); } Audit(retake, "FreeRetakeCreated", $"Học lại một lần của khóa {c.Id}; không phát sinh quyền học lại tiếp."); diff --git a/RikiPath.Application/Services/SupabaseFileStorageService.cs b/RikiPath.Application/Services/SupabaseFileStorageService.cs index 693cb30a..2a8a3607 100644 --- a/RikiPath.Application/Services/SupabaseFileStorageService.cs +++ b/RikiPath.Application/Services/SupabaseFileStorageService.cs @@ -313,6 +313,51 @@ private async Task SignObjectAsync(string bucket, string objectPath, Can return $"{_supabaseUrl}/storage/v1{signedPath}"; } + private static string CohortPreparationPath(int cohortId) + => $"cohort-preparation/{cohortId}/materials.zip"; + + public async Task UploadCohortPreparationZipAsync(int cohortId, Stream contentStream, + CancellationToken cancellationToken) + { + EnsureConfigured(); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(cohortId); + var bucket = await RequirePrivateVerificationBucketAsync(cancellationToken); + var objectPath = CohortPreparationPath(cohortId); + using var content = new StreamContent(contentStream); + content.Headers.ContentType = new MediaTypeHeaderValue("application/zip"); + using var request = new HttpRequestMessage(HttpMethod.Post, + $"/storage/v1/object/{Uri.EscapeDataString(bucket)}/{objectPath}") { Content = content }; + request.Headers.TryAddWithoutValidation("x-upsert", "true"); + using var response = await httpClient.SendAsync(request, cancellationToken); + if (!response.IsSuccessStatusCode) + throw new InvalidOperationException($"Không thể tải ZIP tài liệu lớp lên Supabase (HTTP {(int)response.StatusCode})."); + return $"{_supabaseUrl}/storage/v1/object/authenticated/{Uri.EscapeDataString(bucket)}/{objectPath}"; + } + + public async Task GetCohortPreparationZipDownloadUrlAsync(int cohortId, + CancellationToken cancellationToken) + { + EnsureConfigured(); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(cohortId); + var bucket = await RequirePrivateVerificationBucketAsync(cancellationToken); + var objectPath = CohortPreparationPath(cohortId); + using var info = new HttpRequestMessage(HttpMethod.Head, + $"/storage/v1/object/info/{Uri.EscapeDataString(bucket)}/{objectPath}"); + using var response = await httpClient.SendAsync(info, cancellationToken); + if (response.StatusCode == System.Net.HttpStatusCode.NotFound) return null; + if (!response.IsSuccessStatusCode) + throw new InvalidOperationException($"Không thể kiểm tra ZIP tài liệu lớp trên Supabase (HTTP {(int)response.StatusCode})."); + return await SignObjectAsync(bucket, objectPath, cancellationToken); + } + + public async Task SignCohortPreparationZipAsync(int cohortId, CancellationToken cancellationToken) + { + EnsureConfigured(); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(cohortId); + var bucket = await RequirePrivateVerificationBucketAsync(cancellationToken); + return await SignObjectAsync(bucket, CohortPreparationPath(cohortId), cancellationToken); + } + public async Task VerifyPrivateVerificationAsync(string storedUrl, CancellationToken cancellationToken) { _ = await SignPrivateVerificationUrlAsync(storedUrl, cancellationToken); diff --git a/RikiPath.Domain/AiRuntimeSettings.cs b/RikiPath.Domain/AiRuntimeSettings.cs new file mode 100644 index 00000000..1259927e --- /dev/null +++ b/RikiPath.Domain/AiRuntimeSettings.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace RikiPath.Domain; + +public sealed class AiRuntimeSettings +{ + [JsonPropertyName("OpenAI")] + public OpenAiSettings OpenAi { get; set; } = new(); + public OpenRouterSettings OpenRouter { get; set; } = new(); + public GeminiSettings Gemini { get; set; } = new(); + public TranslationSettings Translation { get; set; } = new(); + public AiSettings Ai { get; set; } = new(); +} diff --git a/RikiPath.Domain/Entities/AiRuntimeConfiguration.cs b/RikiPath.Domain/Entities/AiRuntimeConfiguration.cs new file mode 100644 index 00000000..4ea33d44 --- /dev/null +++ b/RikiPath.Domain/Entities/AiRuntimeConfiguration.cs @@ -0,0 +1,12 @@ +namespace RikiPath.Domain.Entities; + +/// Single active AI configuration. Secrets are protected before persistence. +public sealed class AiRuntimeConfiguration +{ + public int Id { get; set; } = 1; + public string SettingsJson { get; set; } = "{}"; + public string ProtectedSecretsJson { get; set; } = string.Empty; + public int Revision { get; set; } = 1; + public DateTime UpdatedAtUtc { get; set; } = DateTime.UtcNow; + public int UpdatedByAdminId { get; set; } +} diff --git a/RikiPath.Domain/Entities/StudyCohort.cs b/RikiPath.Domain/Entities/StudyCohort.cs index 8ac85b31..e40ab066 100644 --- a/RikiPath.Domain/Entities/StudyCohort.cs +++ b/RikiPath.Domain/Entities/StudyCohort.cs @@ -4,8 +4,8 @@ namespace RikiPath.Domain.Entities; public sealed class StudyCohort { public int Id { get; set; } - public int PlanId { get; set; } - public StudyCoursePlan Plan { get; set; } = null!; + // Learners discover and enroll in the class itself; its level is display and matching data. + public string Level { get; set; } = ""; public string Name { get; set; } = ""; public int MentorId { get; set; } public UserAccount Mentor { get; set; } = null!; diff --git a/RikiPath.Domain/Entities/StudyCohortMentorInvitation.cs b/RikiPath.Domain/Entities/StudyCohortMentorInvitation.cs new file mode 100644 index 00000000..c0524f4a --- /dev/null +++ b/RikiPath.Domain/Entities/StudyCohortMentorInvitation.cs @@ -0,0 +1,30 @@ +namespace RikiPath.Domain.Entities; + +// Each row is one admin offer to teach a class. Earlier decisions remain available for audit. +public sealed class StudyCohortMentorInvitation +{ + public const string Pending = "Pending"; + public const string Accepted = "Accepted"; + public const string Declined = "Declined"; + public const string ChangeRequested = "ChangeRequested"; + public const string Replaced = "Replaced"; + public const string Cancelled = "Cancelled"; + + public int Id { get; set; } + public int CohortId { get; set; } + public StudyCohort Cohort { get; set; } = null!; + public int MentorId { get; set; } + public UserAccount Mentor { get; set; } = null!; + public int? AssignedByAdminId { get; set; } + public UserAccount? AssignedByAdmin { get; set; } + public string Status { get; set; } = Pending; + public string? DeclineReason { get; set; } + public string? ChangeReason { get; set; } + public string? AssignmentReason { get; set; } + public int? FromSessionNumber { get; set; } + public int CohortRevisionAtInvite { get; set; } + public Guid IdempotencyKey { get; set; } + public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow; + public DateTime? RespondedAtUtc { get; set; } + public int Revision { get; set; } = 1; +} diff --git a/RikiPath.Domain/Entities/StudyCourse.cs b/RikiPath.Domain/Entities/StudyCourse.cs index b5ddc9d8..4a352cc7 100644 --- a/RikiPath.Domain/Entities/StudyCourse.cs +++ b/RikiPath.Domain/Entities/StudyCourse.cs @@ -31,8 +31,9 @@ public sealed class StudyCourse public UserAccount Learner { get; set; } = null!; public int? MentorId { get; set; } public UserAccount? Mentor { get; set; } - public int PlanId { get; set; } - public StudyCoursePlan Plan { get; set; } = null!; + // Legacy orders keep their plan; class enrollment no longer requires one. + public int? PlanId { get; set; } + public StudyCoursePlan? Plan { get; set; } public int? RetakeOfId { get; set; } public StudyCourse? RetakeOf { get; set; } public string Name { get; set; } = ""; diff --git a/RikiPath.Infrastructure/AppDbContext.cs b/RikiPath.Infrastructure/AppDbContext.cs index ba0c8518..ce94a9f5 100644 --- a/RikiPath.Infrastructure/AppDbContext.cs +++ b/RikiPath.Infrastructure/AppDbContext.cs @@ -6,6 +6,7 @@ namespace RikiPath.Infrastructure { public class AppDbContext(DbContextOptions options) : DbContext(options) { + public DbSet AiRuntimeConfigurations { get; set; } public DbSet StudyCourses { get; set; } public DbSet StudyCoursePlans { get; set; } @@ -15,6 +16,7 @@ public class AppDbContext(DbContextOptions options) : DbContext(op public DbSet CohortTransferRequests { get; set; } public DbSet CohortTransferRequestEvents { get; set; } public DbSet StudyCohortMentorAssignments { get; set; } + public DbSet StudyCohortMentorInvitations { get; set; } public DbSet CohortScheduleRequests { get; set; } public DbSet CohortScheduleRequestEvents { get; set; } public DbSet CohortMentorReviews { get; set; } @@ -248,6 +250,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.ApplyConfiguration(new UserDeviceTokenConfig()); modelBuilder.ApplyConfiguration(new MentorCalendarConnectionConfig()); + modelBuilder.ApplyConfiguration(new AiRuntimeConfigurationConfig()); modelBuilder.ApplyConfiguration(new StudyCohortConfig()); modelBuilder.ApplyConfiguration(new CohortEnrollmentEntitlementConfig()); modelBuilder.ApplyConfiguration(new StudyCohortSessionConfig()); @@ -256,6 +259,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.ApplyConfiguration(new CohortTransferRequestConfig()); modelBuilder.ApplyConfiguration(new CohortTransferRequestEventConfig()); modelBuilder.ApplyConfiguration(new StudyCohortMentorAssignmentConfig()); + modelBuilder.ApplyConfiguration(new StudyCohortMentorInvitationConfig()); modelBuilder.ApplyConfiguration(new CohortScheduleRequestConfig()); modelBuilder.ApplyConfiguration(new CohortScheduleRequestEventConfig()); modelBuilder.ApplyConfiguration(new CohortMentorReviewConfig()); diff --git a/RikiPath.Infrastructure/Configuration/AiRuntimeConfigurationConfig.cs b/RikiPath.Infrastructure/Configuration/AiRuntimeConfigurationConfig.cs new file mode 100644 index 00000000..d9ee8678 --- /dev/null +++ b/RikiPath.Infrastructure/Configuration/AiRuntimeConfigurationConfig.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using RikiPath.Domain.Entities; + +namespace RikiPath.Infrastructure.Configuration; + +public sealed class AiRuntimeConfigurationConfig : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("AiRuntimeConfigurations", table => + table.HasCheckConstraint("CK_AiRuntimeConfiguration_Singleton", "\"Id\" = 1 AND \"Revision\" > 0")); + builder.HasKey(x => x.Id); + builder.Property(x => x.SettingsJson).HasColumnType("jsonb").IsRequired(); + builder.Property(x => x.ProtectedSecretsJson).IsRequired(); + builder.Property(x => x.Revision).IsConcurrencyToken(); + builder.Property(x => x.UpdatedAtUtc).HasColumnType("timestamp with time zone"); + } +} diff --git a/RikiPath.Infrastructure/Configuration/StudyCohortMentorInvitationConfig.cs b/RikiPath.Infrastructure/Configuration/StudyCohortMentorInvitationConfig.cs new file mode 100644 index 00000000..e9a32a6e --- /dev/null +++ b/RikiPath.Infrastructure/Configuration/StudyCohortMentorInvitationConfig.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using RikiPath.Domain.Entities; + +namespace RikiPath.Infrastructure.Configuration; + +public sealed class StudyCohortMentorInvitationConfig : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder b) + { + b.ToTable("StudyCohortMentorInvitations", t => + { + t.HasCheckConstraint("CK_CohortMentorInvitation_DeclineReason", + "\"Status\" <> 'Declined' OR length(btrim(coalesce(\"DeclineReason\", ''))) > 0"); + t.HasCheckConstraint("CK_CohortMentorInvitation_ChangeReason", + "\"Status\" <> 'ChangeRequested' OR length(btrim(coalesce(\"ChangeReason\", ''))) > 0"); + }); + b.HasKey(x => x.Id); + b.Property(x => x.Status).HasMaxLength(24).IsConcurrencyToken(); + b.Property(x => x.DeclineReason).HasMaxLength(1000); + b.Property(x => x.ChangeReason).HasMaxLength(1000); + b.Property(x => x.AssignmentReason).HasMaxLength(1000); + b.Property(x => x.Revision).IsConcurrencyToken(); + b.Property(x => x.CreatedAtUtc).HasColumnType("timestamp with time zone"); + b.Property(x => x.RespondedAtUtc).HasColumnType("timestamp with time zone"); + b.HasIndex(x => x.IdempotencyKey).IsUnique(); + b.HasIndex(x => x.CohortId).IsUnique().HasFilter("\"Status\" = 'Pending'"); + b.HasIndex(x => new { x.MentorId, x.Status }); + b.HasOne(x => x.Cohort).WithMany().HasForeignKey(x => x.CohortId).OnDelete(DeleteBehavior.Restrict); + b.HasOne(x => x.Mentor).WithMany().HasForeignKey(x => x.MentorId).OnDelete(DeleteBehavior.Restrict); + b.HasOne(x => x.AssignedByAdmin).WithMany().HasForeignKey(x => x.AssignedByAdminId).OnDelete(DeleteBehavior.Restrict); + } +} diff --git a/RikiPath.Infrastructure/Configuration/StudyCourseConfig.cs b/RikiPath.Infrastructure/Configuration/StudyCourseConfig.cs index 1a8efe00..1b3b6c5b 100644 --- a/RikiPath.Infrastructure/Configuration/StudyCourseConfig.cs +++ b/RikiPath.Infrastructure/Configuration/StudyCourseConfig.cs @@ -139,6 +139,7 @@ public void Configure(EntityTypeBuilder b) }); b.HasKey(x => x.Id); b.Property(x => x.Name).HasMaxLength(200); b.Property(x => x.Revision).IsConcurrencyToken(); + b.Property(x => x.Level).HasMaxLength(12).IsRequired(); b.Property(x => x.CourseDurationWeeks).HasDefaultValue(1); b.Property(x => x.EnrollmentOpensAtUtc).HasColumnType("timestamp with time zone"); b.Property(x => x.EnrollmentClosesAtUtc).HasColumnType("timestamp with time zone"); @@ -148,7 +149,6 @@ public void Configure(EntityTypeBuilder b) b.Property(x => x.TuitionPerSessionSnapshot).HasPrecision(18, 0); b.Property(x => x.TotalTuitionSnapshot).HasPrecision(18, 0); b.Property(x => x.TuitionSnapshotAtUtc).HasColumnType("timestamp with time zone"); - b.HasOne(x => x.Plan).WithMany().HasForeignKey(x => x.PlanId).OnDelete(DeleteBehavior.Restrict); b.HasOne(x => x.Mentor).WithMany().HasForeignKey(x => x.MentorId).OnDelete(DeleteBehavior.Restrict); b.HasOne(x => x.GroupPolicy).WithMany().HasForeignKey(x => x.GroupPolicyId).OnDelete(DeleteBehavior.Restrict); b.HasOne(x => x.SourceProposal).WithMany().HasForeignKey(x => x.SourceProposalId).OnDelete(DeleteBehavior.Restrict); diff --git a/RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.Designer.cs b/RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.Designer.cs new file mode 100644 index 00000000..5b3092e1 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.Designer.cs @@ -0,0 +1,14341 @@ +// +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("20261201081546_AddAdminCohortMentorInvitations")] + partial class AddAdminCohortMentorInvitations + { + /// + 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.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.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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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("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_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, + RemediationCompletionThresholdPercent = 90m, + RemediationThresholdComparison = ">", + RequireAdminRemediationReview = true, + RequireOfficialExamEvidence = true, + ReschedulingLeadHours = 24, + RestMinutes = 15, + 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.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.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("CertificateLevelId") + .HasColumnType("integer"); + + 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("LanguageSkillId") + .HasColumnType("integer"); + + 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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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)"); + + 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("LanguageSkillId"); + + b.HasIndex("PassageId"); + + b.HasIndex("QuestionIdentity"); + + b.HasIndex("SourceQuestionId"); + + b.HasIndex("MockTestSectionId", "IsArchivedVersion"); + + b.HasIndex("CertificateLevelId", "LanguageSkillId", "PublishStatus", "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("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)"); + + 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("MentorId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlanId") + .HasColumnType("integer"); + + 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("PlanId"); + + 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.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.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.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.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") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.ContentPassage", "Passage") + .WithMany("Questions") + .HasForeignKey("PassageId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.MockQuestion", null) + .WithMany() + .HasForeignKey("SourceQuestionId") + .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.StudyCoursePlan", "Plan") + .WithMany() + .HasForeignKey("PlanId") + .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("Plan"); + + 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) + .IsRequired(); + + 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.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/20261201081546_AddAdminCohortMentorInvitations.cs b/RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.cs new file mode 100644 index 00000000..25dc46e3 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201081546_AddAdminCohortMentorInvitations.cs @@ -0,0 +1,92 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + /// + public partial class AddAdminCohortMentorInvitations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "StudyCohortMentorInvitations", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CohortId = table.Column(type: "integer", nullable: false), + MentorId = table.Column(type: "integer", nullable: false), + AssignedByAdminId = table.Column(type: "integer", nullable: true), + Status = table.Column(type: "character varying(24)", maxLength: 24, nullable: false), + DeclineReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + ChangeReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + AssignmentReason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + FromSessionNumber = table.Column(type: "integer", nullable: true), + CohortRevisionAtInvite = table.Column(type: "integer", nullable: false), + IdempotencyKey = table.Column(type: "uuid", nullable: false), + CreatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), + RespondedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), + Revision = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_StudyCohortMentorInvitations", x => x.Id); + table.CheckConstraint("CK_CohortMentorInvitation_ChangeReason", "\"Status\" <> 'ChangeRequested' OR length(btrim(coalesce(\"ChangeReason\", ''))) > 0"); + table.CheckConstraint("CK_CohortMentorInvitation_DeclineReason", "\"Status\" <> 'Declined' OR length(btrim(coalesce(\"DeclineReason\", ''))) > 0"); + table.ForeignKey( + name: "FK_StudyCohortMentorInvitations_StudyCohorts_CohortId", + column: x => x.CohortId, + principalTable: "StudyCohorts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_StudyCohortMentorInvitations_Users_AssignedByAdminId", + column: x => x.AssignedByAdminId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_StudyCohortMentorInvitations_Users_MentorId", + column: x => x.MentorId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_StudyCohortMentorInvitations_AssignedByAdminId", + table: "StudyCohortMentorInvitations", + column: "AssignedByAdminId"); + + migrationBuilder.CreateIndex( + name: "IX_StudyCohortMentorInvitations_CohortId", + table: "StudyCohortMentorInvitations", + column: "CohortId", + unique: true, + filter: "\"Status\" = 'Pending'"); + + migrationBuilder.CreateIndex( + name: "IX_StudyCohortMentorInvitations_IdempotencyKey", + table: "StudyCohortMentorInvitations", + column: "IdempotencyKey", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_StudyCohortMentorInvitations_MentorId_Status", + table: "StudyCohortMentorInvitations", + columns: new[] { "MentorId", "Status" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DO $$ BEGIN IF EXISTS (SELECT 1 FROM \"StudyCohortMentorInvitations\") THEN RAISE EXCEPTION 'Export mentor invitation history before rollback'; END IF; END $$;"); + migrationBuilder.DropTable( + name: "StudyCohortMentorInvitations"); + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.Designer.cs b/RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.Designer.cs new file mode 100644 index 00000000..d8a66e99 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.Designer.cs @@ -0,0 +1,14332 @@ +// +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("20261201132000_MakeCohortsPlanless")] + partial class MakeCohortsPlanless + { + /// + 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.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.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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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("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_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, + RemediationCompletionThresholdPercent = 90m, + RemediationThresholdComparison = ">", + RequireAdminRemediationReview = true, + RequireOfficialExamEvidence = true, + ReschedulingLeadHours = 24, + RestMinutes = 15, + 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.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.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("CertificateLevelId") + .HasColumnType("integer"); + + 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("LanguageSkillId") + .HasColumnType("integer"); + + 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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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)"); + + 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("LanguageSkillId"); + + b.HasIndex("PassageId"); + + b.HasIndex("QuestionIdentity"); + + b.HasIndex("SourceQuestionId"); + + b.HasIndex("MockTestSectionId", "IsArchivedVersion"); + + b.HasIndex("CertificateLevelId", "LanguageSkillId", "PublishStatus", "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("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)"); + + 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.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.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.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.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") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.ContentPassage", "Passage") + .WithMany("Questions") + .HasForeignKey("PassageId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.MockQuestion", null) + .WithMany() + .HasForeignKey("SourceQuestionId") + .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.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/20261201132000_MakeCohortsPlanless.cs b/RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.cs new file mode 100644 index 00000000..2b15ded5 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201132000_MakeCohortsPlanless.cs @@ -0,0 +1,82 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + /// + public partial class MakeCohortsPlanless : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Level", + table: "StudyCohorts", + type: "character varying(12)", + maxLength: 12, + nullable: true); + + // Retain legacy class identity and tuition before removing the plan relationship. + migrationBuilder.Sql(""" + UPDATE "StudyCohorts" AS c + SET "Level" = upper(btrim(l."Code")), + "TotalTuitionSnapshot" = COALESCE(c."TotalTuitionSnapshot", p."Price"), + "CourseDurationWeeks" = CASE + WHEN c."CourseDurationWeeks" > 1 THEN c."CourseDurationWeeks" + WHEN p."SessionsPerWeek" > 0 AND p."TotalSessions" > 0 + THEN GREATEST(1, CEIL(p."TotalSessions"::numeric / p."SessionsPerWeek")::integer) + ELSE 1 END + FROM "StudyCoursePlans" AS p + JOIN "CertificateLevels" AS l ON l."Id" = p."CertificateLevelId" + WHERE c."PlanId" = p."Id"; + """); + + migrationBuilder.Sql(""" + DO $$ BEGIN + IF EXISTS (SELECT 1 FROM "StudyCohorts" WHERE "Level" IS NULL OR length(btrim("Level")) = 0) THEN + RAISE EXCEPTION 'Legacy cohort level backfill failed; PlanId was preserved'; + END IF; + END $$; + """); + + migrationBuilder.AlterColumn( + name: "Level", + table: "StudyCohorts", + type: "character varying(12)", + maxLength: 12, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(12)", + oldMaxLength: 12, + oldNullable: true); + + migrationBuilder.DropForeignKey( + name: "FK_StudyCohorts_StudyCoursePlans_PlanId", + table: "StudyCohorts"); + + migrationBuilder.DropIndex( + name: "IX_StudyCohorts_PlanId", + table: "StudyCohorts"); + + migrationBuilder.DropColumn( + name: "PlanId", + table: "StudyCohorts"); + + migrationBuilder.AlterColumn( + name: "PlanId", + table: "StudyCourses", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DO $$ BEGIN RAISE EXCEPTION 'Planless classes cannot be converted back to plan-linked classes; use a reviewed forward migration'; END $$;"); + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.Designer.cs b/RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.Designer.cs new file mode 100644 index 00000000..8abe0c0f --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.Designer.cs @@ -0,0 +1,14332 @@ +// +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("20261201135156_RepairCohortInvitationRevision")] + partial class RepairCohortInvitationRevision + { + /// + 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.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.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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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("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_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, + RemediationCompletionThresholdPercent = 90m, + RemediationThresholdComparison = ">", + RequireAdminRemediationReview = true, + RequireOfficialExamEvidence = true, + ReschedulingLeadHours = 24, + RestMinutes = 15, + 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.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.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("CertificateLevelId") + .HasColumnType("integer"); + + 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("LanguageSkillId") + .HasColumnType("integer"); + + 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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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)"); + + 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("LanguageSkillId"); + + b.HasIndex("PassageId"); + + b.HasIndex("QuestionIdentity"); + + b.HasIndex("SourceQuestionId"); + + b.HasIndex("MockTestSectionId", "IsArchivedVersion"); + + b.HasIndex("CertificateLevelId", "LanguageSkillId", "PublishStatus", "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("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)"); + + 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.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.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.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.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") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.ContentPassage", "Passage") + .WithMany("Questions") + .HasForeignKey("PassageId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.MockQuestion", null) + .WithMany() + .HasForeignKey("SourceQuestionId") + .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.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/20261201135156_RepairCohortInvitationRevision.cs b/RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.cs new file mode 100644 index 00000000..288dfdc5 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201135156_RepairCohortInvitationRevision.cs @@ -0,0 +1,56 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + /// + public partial class RepairCohortInvitationRevision : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + DO $$ + BEGIN + IF to_regclass('public."StudyCohortMentorInvitations"') IS NULL THEN + RAISE EXCEPTION 'StudyCohortMentorInvitations is missing; review migration history before repair'; + END IF; + + LOCK TABLE public."StudyCohortMentorInvitations" IN ACCESS EXCLUSIVE MODE; + + IF NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'StudyCohortMentorInvitations' + AND column_name = 'CohortRevisionAtInvite' + ) THEN + IF EXISTS (SELECT 1 FROM public."StudyCohortMentorInvitations") THEN + RAISE EXCEPTION 'Cannot reconstruct CohortRevisionAtInvite for existing invitations; repair manually'; + END IF; + + ALTER TABLE public."StudyCohortMentorInvitations" + ADD COLUMN "CohortRevisionAtInvite" integer NOT NULL; + END IF; + + IF NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'StudyCohortMentorInvitations' + AND column_name = 'CohortRevisionAtInvite' + AND data_type = 'integer' + AND is_nullable = 'NO' + ) THEN + RAISE EXCEPTION 'CohortRevisionAtInvite has an incompatible definition; review schema before repair'; + END IF; + END $$; + """); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + // The original invitation migration owns this column; reverting the repair must not remove it. + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.Designer.cs b/RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.Designer.cs new file mode 100644 index 00000000..1d4f4555 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.Designer.cs @@ -0,0 +1,14366 @@ +// +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("20261201143534_AddAdminAiRuntimeConfiguration")] + partial class AddAdminAiRuntimeConfiguration + { + /// + 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.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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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("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_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, + RemediationCompletionThresholdPercent = 90m, + RemediationThresholdComparison = ">", + RequireAdminRemediationReview = true, + RequireOfficialExamEvidence = true, + ReschedulingLeadHours = 24, + RestMinutes = 15, + 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.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.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("CertificateLevelId") + .HasColumnType("integer"); + + 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("LanguageSkillId") + .HasColumnType("integer"); + + 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("PublishStatus") + .HasColumnType("integer"); + + b.Property("PublishedAt") + .HasColumnType("timestamp without time zone"); + + 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("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)"); + + 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("LanguageSkillId"); + + b.HasIndex("PassageId"); + + b.HasIndex("QuestionIdentity"); + + b.HasIndex("SourceQuestionId"); + + b.HasIndex("MockTestSectionId", "IsArchivedVersion"); + + b.HasIndex("CertificateLevelId", "LanguageSkillId", "PublishStatus", "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("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)"); + + 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.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.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.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.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") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("RikiPath.Domain.Entities.ContentPassage", "Passage") + .WithMany("Questions") + .HasForeignKey("PassageId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("RikiPath.Domain.Entities.MockQuestion", null) + .WithMany() + .HasForeignKey("SourceQuestionId") + .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.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/20261201143534_AddAdminAiRuntimeConfiguration.cs b/RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.cs new file mode 100644 index 00000000..391ef311 --- /dev/null +++ b/RikiPath.Infrastructure/Migrations/20261201143534_AddAdminAiRuntimeConfiguration.cs @@ -0,0 +1,42 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace RikiPath.Infrastructure.Migrations +{ + /// + public partial class AddAdminAiRuntimeConfiguration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AiRuntimeConfigurations", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SettingsJson = table.Column(type: "jsonb", nullable: false), + ProtectedSecretsJson = table.Column(type: "text", nullable: false), + Revision = table.Column(type: "integer", nullable: false), + UpdatedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedByAdminId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AiRuntimeConfigurations", x => x.Id); + table.CheckConstraint("CK_AiRuntimeConfiguration_Singleton", "\"Id\" = 1 AND \"Revision\" > 0"); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DO $$ BEGIN IF EXISTS (SELECT 1 FROM \"AiRuntimeConfigurations\") THEN RAISE EXCEPTION 'Export AI runtime configuration before rollback'; END IF; END $$;"); + migrationBuilder.DropTable( + name: "AiRuntimeConfigurations"); + } + } +} diff --git a/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 47e9450d..9b161821 100644 --- a/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/RikiPath.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -359,6 +359,40 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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") @@ -9759,6 +9793,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("GroupPolicyId") .HasColumnType("integer"); + b.Property("Level") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("character varying(12)"); + b.Property("MentorId") .HasColumnType("integer"); @@ -9767,9 +9806,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(200) .HasColumnType("character varying(200)"); - b.Property("PlanId") - .HasColumnType("integer"); - b.Property("PolicyVersionSnapshot") .HasColumnType("integer"); @@ -9807,8 +9843,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("MentorId"); - b.HasIndex("PlanId"); - b.HasIndex("SourceProposalId") .IsUnique() .HasFilter("\"SourceProposalId\" IS NOT NULL"); @@ -9896,6 +9930,81 @@ protected override void BuildModel(ModelBuilder modelBuilder) }); }); + 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") @@ -10023,7 +10132,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("text"); - b.Property("PlanId") + b.Property("PlanId") .HasColumnType("integer"); b.Property("PlanRevision") @@ -13617,12 +13726,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("RikiPath.Domain.Entities.StudyCoursePlan", "Plan") - .WithMany() - .HasForeignKey("PlanId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - b.HasOne("RikiPath.Domain.Entities.MentorTeachingProposal", "SourceProposal") .WithMany() .HasForeignKey("SourceProposalId") @@ -13632,8 +13735,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Mentor"); - b.Navigation("Plan"); - b.Navigation("SourceProposal"); }); @@ -13671,6 +13772,32 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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") @@ -13722,8 +13849,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("RikiPath.Domain.Entities.StudyCoursePlan", "Plan") .WithMany() .HasForeignKey("PlanId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); + .OnDelete(DeleteBehavior.Restrict); b.HasOne("RikiPath.Domain.Entities.StudyCourse", "RetakeOf") .WithMany() diff --git a/RikiPath.Infrastructure/OpenAiRegistration.cs b/RikiPath.Infrastructure/OpenAiRegistration.cs index 5c7ab1d5..15d9f5ab 100644 --- a/RikiPath.Infrastructure/OpenAiRegistration.cs +++ b/RikiPath.Infrastructure/OpenAiRegistration.cs @@ -1,8 +1,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using RikiPath.Application.IServices; using RikiPath.Application.IClients; using RikiPath.Domain; using RikiPath.Infrastructure.Clients; +using RikiPath.Infrastructure.Services; namespace RikiPath.Infrastructure; @@ -10,28 +13,20 @@ public static class OpenAiRegistration { public static IServiceCollection AddOpenAiFeatures(this IServiceCollection services, IConfiguration configuration) { - services.Configure(settings => - { - configuration.GetSection("AppSettings:OpenAI").Bind(settings); - configuration.GetSection("OpenAI").Bind(settings); - var key = configuration["OPENAI_API_KEY"]; - if (!string.IsNullOrWhiteSpace(key)) settings.ApiKey = key; - }); - services.Configure(settings => - { - configuration.GetSection("AppSettings:OpenRouter").Bind(settings); - configuration.GetSection("OpenRouter").Bind(settings); - }); - services.Configure(settings => - { - configuration.GetSection("AppSettings:Gemini").Bind(settings); - configuration.GetSection("GeminiSettings").Bind(settings); - }); - services.Configure(settings => - { - configuration.GetSection("AppSettings:Translation").Bind(settings); - configuration.GetSection("Translation").Bind(settings); - }); + services.AddSingleton(); + services.AddSingleton>(sp => new AiLiveOptions( + sp.GetRequiredService(), x => x.OpenAi)); + services.AddSingleton>(sp => new AiLiveOptions( + sp.GetRequiredService(), x => x.OpenRouter)); + services.AddSingleton>(sp => new AiLiveOptions( + sp.GetRequiredService(), x => x.Gemini)); + services.AddSingleton>(sp => new AiLiveOptions( + sp.GetRequiredService(), x => x.Translation)); + services.AddSingleton>(sp => new AiLiveOptions( + sp.GetRequiredService(), x => x.Ai)); + services.AddScoped(); + services.AddScoped(sp => sp.GetRequiredService()); + services.AddHostedService(); services.AddHttpClient("translation-provider", http => http.Timeout = Timeout.InfiniteTimeSpan); services.AddHttpClient(http => http.Timeout = Timeout.InfiniteTimeSpan); services.AddScoped(); diff --git a/RikiPath.Infrastructure/Repositories/LessonRepository.cs b/RikiPath.Infrastructure/Repositories/LessonRepository.cs index 23641982..c559f1dd 100644 --- a/RikiPath.Infrastructure/Repositories/LessonRepository.cs +++ b/RikiPath.Infrastructure/Repositories/LessonRepository.cs @@ -79,7 +79,21 @@ public async Task> GetAssessmentRoadmapLe int lessonId, CancellationToken cancellationToken = default) { - return await LearnerVisibleLessons() + return await LearnerVisibleWithBankLinks() + .FirstOrDefaultAsync(lesson => lesson.Id == lessonId, cancellationToken); + } + + public async Task> GetLearnerVisibleByIdsAsync( + IReadOnlyCollection lessonIds, + CancellationToken cancellationToken = default) + { + if (lessonIds.Count == 0) return []; + return await LearnerVisibleWithBankLinks() + .Where(lesson => lessonIds.Contains(lesson.Id)) + .ToListAsync(cancellationToken); + } + + private IQueryable LearnerVisibleWithBankLinks() => LearnerVisibleLessons() .Include(lesson => lesson.CertificateLevel) .ThenInclude(level => level.CertificateType) .Include(lesson => lesson.LanguageSkill) @@ -92,9 +106,7 @@ public async Task> GetAssessmentRoadmapLe .Include(lesson => lesson.LessonGrammars! .Where(link => !link.GrammarPattern.IsDeleted && link.GrammarPattern.Status == ContentStatus.Published)) .ThenInclude(link => link.GrammarPattern) - .AsSplitQuery() - .FirstOrDefaultAsync(lesson => lesson.Id == lessonId, cancellationToken); - } + .AsSplitQuery(); private IQueryable LearnerVisibleLessons() => _context.Lessons.AsNoTracking().Where(lesson => @@ -141,5 +153,43 @@ public async Task> GetByCertificateLevelAsync(int certific .OrderBy(x => x.SortOrder) .ThenBy(x => x.Id) .ToListAsync(cancellationToken); + + public async Task<(int Total, Lesson? Lesson)> GetByCertificateLevelPositionAsync( + int certificateLevelId, int zeroBasedPosition, CancellationToken cancellationToken = default) + { + var visible = _context.Lessons.AsNoTracking().Where(lesson => + lesson.CertificateLevelId == certificateLevelId + && !lesson.IsDeleted + && lesson.Status == ContentStatus.Published + && !lesson.CertificateLevel.IsDeleted + && !lesson.CertificateLevel.CertificateType.IsDeleted + && lesson.CertificateLevel.CertificateType.IsActive + && lesson.CertificateLevel.CertificateType.Name == "JLPT" + && !lesson.LanguageSkill.IsDeleted); + + var total = await visible.CountAsync(cancellationToken); + if (zeroBasedPosition < 0 || zeroBasedPosition >= total) + return (total, null); + + var lesson = await visible + .OrderBy(x => x.SortOrder) + .ThenBy(x => x.Id) + .Skip(zeroBasedPosition) + .Include(x => x.LanguageSkill) + .Include(x => x.Topic) + .Include(x => x.LessonKanjis!.Where(link => + !link.Kanji.IsDeleted && link.Kanji.Status == ContentStatus.Published)) + .ThenInclude(link => link.Kanji) + .Include(x => x.LessonVocabularies!.Where(link => + !link.Vocabulary.IsDeleted && link.Vocabulary.Status == ContentStatus.Published)) + .ThenInclude(link => link.Vocabulary) + .Include(x => x.LessonGrammars!.Where(link => + !link.GrammarPattern.IsDeleted && link.GrammarPattern.Status == ContentStatus.Published)) + .ThenInclude(link => link.GrammarPattern) + .AsSplitQuery() + .FirstOrDefaultAsync(cancellationToken); + + return (total, lesson); + } } } diff --git a/RikiPath.Infrastructure/Services/AiRuntimeConfigurationService.cs b/RikiPath.Infrastructure/Services/AiRuntimeConfigurationService.cs new file mode 100644 index 00000000..9b0d3d4d --- /dev/null +++ b/RikiPath.Infrastructure/Services/AiRuntimeConfigurationService.cs @@ -0,0 +1,296 @@ +using System.Net; +using System.Text.Json; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Npgsql; +using RikiPath.Application.IServices; +using RikiPath.Application.Requests.AdminConfig; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.AdminConfig; +using RikiPath.Domain; +using RikiPath.Domain.Entities; + +namespace RikiPath.Infrastructure.Services; + +public sealed class AiRuntimeConfigurationCache +{ + private AiRuntimeSettings _current; + + public AiRuntimeConfigurationCache(IConfiguration configuration) + { + var fallback = new AiRuntimeSettings(); + configuration.GetSection("AppSettings:OpenAI").Bind(fallback.OpenAi); + configuration.GetSection("OpenAI").Bind(fallback.OpenAi); + var key = configuration["OPENAI_API_KEY"]; + if (!string.IsNullOrWhiteSpace(key)) fallback.OpenAi.ApiKey = key; + configuration.GetSection("AppSettings:OpenRouter").Bind(fallback.OpenRouter); + configuration.GetSection("OpenRouter").Bind(fallback.OpenRouter); + configuration.GetSection("AppSettings:Gemini").Bind(fallback.Gemini); + configuration.GetSection("GeminiSettings").Bind(fallback.Gemini); + configuration.GetSection("AppSettings:Translation").Bind(fallback.Translation); + configuration.GetSection("Translation").Bind(fallback.Translation); + configuration.GetSection("AppSettings:Ai").Bind(fallback.Ai); + configuration.GetSection("Ai").Bind(fallback.Ai); + Fallback = fallback; + _current = fallback; + } + + public AiRuntimeSettings Fallback { get; } + public AiRuntimeSettings Current => Volatile.Read(ref _current); + public void Publish(AiRuntimeSettings settings) => Volatile.Write(ref _current, settings); +} + +public sealed class AiLiveOptions(AiRuntimeConfigurationCache cache, Func select) : IOptions + where T : class +{ + public T Value => select(cache.Current); +} + +public sealed class AiRuntimeConfigurationService( + AppDbContext db, + IDataProtectionProvider protection, + AiRuntimeConfigurationCache cache) : IAdminAiConfigurationService +{ + private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web); + private readonly IDataProtector _protector = protection.CreateProtector("RikiPath.AiRuntimeConfiguration.Secrets.v1"); + + private sealed class Secrets + { + public string OpenAiApiKey { get; set; } = string.Empty; + public string OpenRouterApiKey { get; set; } = string.Empty; + public List GeminiApiKeys { get; set; } = []; + } + + public async Task> GetAsync(CancellationToken ct) + { + var row = await db.AiRuntimeConfigurations.AsNoTracking().SingleOrDefaultAsync(x => x.Id == 1, ct); + var (settings, secrets) = Decode(row); + return ApiResponse.Success(ToResponse(row, settings, secrets)); + } + + public async Task> UpdateAsync( + AdminAiConfigurationRequest request, int adminId, CancellationToken ct) + { + if (request?.Settings is null) + return ApiResponse.Fail( + "Cấu hình AI không hợp lệ.", HttpStatusCode.BadRequest, "AI_CONFIG_INVALID"); + if (!Valid(request.Settings, request, out var validationError)) + return ApiResponse.Fail( + validationError!, HttpStatusCode.BadRequest, "AI_CONFIG_INVALID"); + + var row = await db.AiRuntimeConfigurations.SingleOrDefaultAsync(x => x.Id == 1, ct); + var currentRevision = row?.Revision ?? 0; + if (request.ExpectedRevision != currentRevision) + return ApiResponse.Fail( + "Cấu hình AI đã được cập nhật. Vui lòng tải lại.", HttpStatusCode.Conflict, "AI_CONFIG_REVISION_CONFLICT"); + + var (previousSettings, secrets) = Decode(row); + if (request.ClearOpenAiApiKey) secrets.OpenAiApiKey = string.Empty; + else if (!string.IsNullOrWhiteSpace(request.OpenAiApiKey)) secrets.OpenAiApiKey = request.OpenAiApiKey.Trim(); + else if (!string.IsNullOrWhiteSpace(request.Settings.OpenAi.ApiKey)) + secrets.OpenAiApiKey = request.Settings.OpenAi.ApiKey.Trim(); + if (request.ClearOpenRouterApiKey) secrets.OpenRouterApiKey = string.Empty; + else if (!string.IsNullOrWhiteSpace(request.OpenRouterApiKey)) secrets.OpenRouterApiKey = request.OpenRouterApiKey.Trim(); + if (request.ClearGeminiApiKeys) secrets.GeminiApiKeys = []; + else if (request.GeminiApiKeys is not null) + secrets.GeminiApiKeys = request.GeminiApiKeys.Select(x => x.Trim()).ToList(); + + var editable = Clone(request.Settings); + editable.OpenAi.ApiKey = string.Empty; + editable.OpenRouter.ApiKey = string.Empty; + editable.Gemini.ApiKey = []; + var now = DateTime.UtcNow; + var previousSecrets = row is null ? null : DecodeSecrets(row); + var before = row is null ? null : JsonSerializer.Serialize(new + { + Settings = PublicCopy(previousSettings), + OpenAiKeyConfigured = !string.IsNullOrEmpty(previousSecrets!.OpenAiApiKey), + OpenRouterKeyConfigured = !string.IsNullOrEmpty(previousSecrets.OpenRouterApiKey), + GeminiKeyCount = previousSecrets.GeminiApiKeys.Count + }, JsonOptions); + row ??= new AiRuntimeConfiguration { Id = 1 }; + row.SettingsJson = JsonSerializer.Serialize(editable, JsonOptions); + row.ProtectedSecretsJson = _protector.Protect(JsonSerializer.Serialize(secrets, JsonOptions)); + row.Revision = currentRevision + 1; + row.UpdatedAtUtc = now; + row.UpdatedByAdminId = adminId; + if (currentRevision == 0) db.AiRuntimeConfigurations.Add(row); + db.AdminAuditLogs.Add(new AdminAuditLog + { + ActorUserId = adminId, + EntityType = "AiRuntimeConfiguration", + EntityId = 1, + Action = currentRevision == 0 ? "Created" : "Updated", + BeforeJson = before, + AfterJson = JsonSerializer.Serialize(new + { + Settings = editable, + OpenAiKeyConfigured = !string.IsNullOrEmpty(secrets.OpenAiApiKey), + OpenRouterKeyConfigured = !string.IsNullOrEmpty(secrets.OpenRouterApiKey), + GeminiKeyCount = secrets.GeminiApiKeys.Count + }, JsonOptions), + Reason = null, + CreatedAtUtc = now + }); + try + { + await db.SaveChangesAsync(ct); + } + catch (DbUpdateException ex) when (ex is DbUpdateConcurrencyException + || ex.InnerException is PostgresException { SqlState: PostgresErrorCodes.UniqueViolation }) + { + return ApiResponse.Fail( + "Cấu hình AI đã được cập nhật. Vui lòng tải lại.", HttpStatusCode.Conflict, "AI_CONFIG_REVISION_CONFLICT"); + } + + cache.Publish(WithSecrets(editable, secrets)); + return ApiResponse.Success(ToResponse(row, editable, secrets)); + } + + public async Task RefreshCacheAsync(CancellationToken ct) + { + var row = await db.AiRuntimeConfigurations.AsNoTracking().SingleOrDefaultAsync(x => x.Id == 1, ct); + var (settings, _) = Decode(row); + cache.Publish(settings); + } + + private (AiRuntimeSettings Settings, Secrets Secrets) Decode(AiRuntimeConfiguration? row) + { + if (row is null) + { + var fallback = Clone(cache.Fallback); + return (fallback, new Secrets + { + OpenAiApiKey = fallback.OpenAi.ApiKey, + OpenRouterApiKey = fallback.OpenRouter.ApiKey, + GeminiApiKeys = fallback.Gemini.ApiKey.ToList() + }); + } + var settings = JsonSerializer.Deserialize(row.SettingsJson, JsonOptions) + ?? throw new InvalidOperationException("Stored AI configuration is invalid."); + var secrets = DecodeSecrets(row); + return (WithSecrets(settings, secrets), secrets); + } + + private Secrets DecodeSecrets(AiRuntimeConfiguration row) + => JsonSerializer.Deserialize(_protector.Unprotect(row.ProtectedSecretsJson), JsonOptions) + ?? throw new InvalidOperationException("Stored AI secrets are invalid."); + + private static AiRuntimeSettings WithSecrets(AiRuntimeSettings settings, Secrets secrets) + { + settings.OpenAi.ApiKey = secrets.OpenAiApiKey; + settings.OpenRouter.ApiKey = secrets.OpenRouterApiKey; + settings.Gemini.ApiKey = secrets.GeminiApiKeys.ToList(); + return settings; + } + + private static AiRuntimeSettings Clone(AiRuntimeSettings settings) + => JsonSerializer.Deserialize(JsonSerializer.Serialize(settings, JsonOptions), JsonOptions)!; + + private static AiRuntimeSettings PublicCopy(AiRuntimeSettings settings) + { + var copy = Clone(settings); + copy.OpenAi.ApiKey = string.Empty; + copy.OpenRouter.ApiKey = string.Empty; + copy.Gemini.ApiKey = []; + return copy; + } + + private static AdminAiConfigurationResponse ToResponse( + AiRuntimeConfiguration? row, AiRuntimeSettings settings, Secrets secrets) + => new(PublicCopy(settings), + !string.IsNullOrWhiteSpace(secrets.OpenAiApiKey), + !string.IsNullOrWhiteSpace(secrets.OpenRouterApiKey), + secrets.GeminiApiKeys.Count, + row?.Revision ?? 0, row?.UpdatedAtUtc, row?.UpdatedByAdminId, + row is null ? "appsettings" : "database"); + + private static bool Valid(AiRuntimeSettings settings, AdminAiConfigurationRequest request, out string? error) + { + error = null; + if (settings.OpenAi is null || settings.OpenRouter is null || settings.Gemini is null + || settings.Translation is null || settings.Ai?.RateLimit is null) + error = "Thiếu nhóm cấu hình AI."; + else if (!ValidUrl(settings.OpenAi.BaseUrl, "api.openai.com", "/v1/") + || !ValidUrl(settings.OpenRouter.BaseUrl, "openrouter.ai", "/api/v1") + || !ValidUrl(settings.Gemini.BaseUrl, "generativelanguage.googleapis.com", "/v1beta/models/", prefix: true)) + error = "URL provider AI phải là endpoint HTTPS chính thức."; + else if (new[] { settings.OpenAi.LearningPathModel, settings.OpenAi.ContentModel, + settings.OpenAi.ReviewModel, settings.OpenAi.GradingModel, settings.OpenAi.OcrModel, + settings.OpenAi.TranscriptionModel, settings.OpenRouter.Model } + .Any(x => string.IsNullOrWhiteSpace(x) || x.Length > 150 || x.Any(char.IsControl))) + error = "Tên model AI phải có từ 1 đến 150 ký tự."; + else if (settings.OpenAi.TimeoutSeconds is < 1 or > 600 + || settings.OpenAi.MaxOutputTokens is < 1 or > 100000 + || settings.OpenAi.LearningPathMaxOutputTokens is < 1 or > 100000 + || settings.OpenRouter.TimeoutSeconds is < 1 or > 120 + || settings.OpenRouter.MaxOutputTokens is < 1 or > 100000 + || settings.Gemini.TimeoutSeconds is < 1 or > 120) + error = "Timeout hoặc giới hạn token AI nằm ngoài phạm vi cho phép."; + else if (settings.Translation.MaxTextLength is < 1 or > 10000 + || settings.Translation.DailyRequestsPerUser is < 1 or > 10000 + || settings.Translation.DailyTokensPerUser is < 1 or > 10000000 + || settings.Translation.CacheHours is < 1 or > 168 + || settings.Translation.ProviderTimeoutSeconds is < 1 or > 120 + || settings.Ai.RateLimit.MaxRequestsPerUserPerDay is < 1 or > 10000 + || settings.Ai.RateLimit.MaxTokensPerUserPerDay is < 1 or > 10000000) + error = "Hạn mức AI hoặc dịch thuật nằm ngoài phạm vi cho phép."; + else if (settings.Ai.RateLimit.UnlimitedUserEmails is null + || settings.Ai.RateLimit.UnlimitedUserEmails.Count > 50 + || settings.Ai.RateLimit.UnlimitedUserEmails.Any(x => string.IsNullOrWhiteSpace(x) || x.Length > 254 || !x.Contains('@'))) + error = "Danh sách tài khoản không giới hạn AI không hợp lệ."; + else if ((request.OpenAiApiKey?.Length ?? 0) > 4096 + || (settings.OpenAi.ApiKey?.Length ?? 0) > 4096 + || (request.OpenRouterApiKey?.Length ?? 0) > 4096 + || request.GeminiApiKeys is { Count: > 2 } + || request.GeminiApiKeys?.Any(x => string.IsNullOrWhiteSpace(x) || x.Length > 4096) == true + || (request.Reason?.Length ?? 0) > 500) + error = "API key hoặc lý do cập nhật vượt giới hạn."; + else if ((request.ClearOpenAiApiKey && (!string.IsNullOrWhiteSpace(request.OpenAiApiKey) + || !string.IsNullOrWhiteSpace(settings.OpenAi.ApiKey))) + || (request.ClearOpenRouterApiKey && !string.IsNullOrWhiteSpace(request.OpenRouterApiKey)) + || (request.ClearGeminiApiKeys && request.GeminiApiKeys is not null)) + error = "Không thể vừa thay vừa xóa cùng một API key."; + else if (!string.IsNullOrWhiteSpace(request.OpenAiApiKey) + && !string.IsNullOrWhiteSpace(settings.OpenAi.ApiKey) + && !string.Equals(request.OpenAiApiKey.Trim(), settings.OpenAi.ApiKey.Trim(), StringComparison.Ordinal)) + error = "Chỉ gửi ApiKey một lần trong cấu hình OpenAI."; + return error is null; + } + + private static bool ValidUrl(string? value, string host, string path, bool prefix = false) + => Uri.TryCreate(value, UriKind.Absolute, out var uri) + && uri.Scheme == Uri.UriSchemeHttps && uri.Host.Equals(host, StringComparison.OrdinalIgnoreCase) + && uri.Port == 443 && string.IsNullOrEmpty(uri.UserInfo) + && string.IsNullOrEmpty(uri.Query) && string.IsNullOrEmpty(uri.Fragment) + && (prefix ? uri.AbsolutePath.StartsWith(path, StringComparison.Ordinal) + : uri.AbsolutePath.TrimEnd('/').Equals(path.TrimEnd('/'), StringComparison.Ordinal)); +} + +public sealed class AiRuntimeConfigurationRefreshWorker( + IServiceScopeFactory scopes, ILogger logger) : BackgroundService +{ + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + try + { + using var scope = scopes.CreateScope(); + await scope.ServiceProvider.GetRequiredService() + .RefreshCacheAsync(stoppingToken); + } + catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) { break; } + catch (Exception ex) + { + logger.LogWarning(ex, "Could not refresh AI runtime configuration; keeping last known settings"); + } + await Task.Delay(TimeSpan.FromSeconds(15), stoppingToken); + } + } +} diff --git a/RikiPath.Infrastructure/Services/CohortEnrollmentDeadlineService.cs b/RikiPath.Infrastructure/Services/CohortEnrollmentDeadlineService.cs index 4bab2876..6ed1af0a 100644 --- a/RikiPath.Infrastructure/Services/CohortEnrollmentDeadlineService.cs +++ b/RikiPath.Infrastructure/Services/CohortEnrollmentDeadlineService.cs @@ -163,7 +163,6 @@ await unitOfWork.ExecuteInTransactionAsync(async token => await unitOfWork.StudyCourses.LockScheduleAsync(mentorId.Value, mentorId.Value, token); var cohort = await db.StudyCohorts - .Include(c => c.Plan).ThenInclude(p => p.CertificateLevel) .Include(c => c.GroupPolicy) .Include(c => c.Sessions).ThenInclude(s => s.Availability).ThenInclude(a => a.GroupPolicy) .Include(c => c.Enrollments).ThenInclude(e => e.Audit) @@ -316,7 +315,7 @@ await unitOfWork.ExecuteInTransactionAsync(async token => if (!alreadyNotified) { - var levelCode = cohort.Plan?.CertificateLevel?.Code?.Trim(); + var levelCode = cohort.Level.Trim(); var levelLabel = string.IsNullOrWhiteSpace(levelCode) ? "JLPT" : levelCode; var notifications = new List(1 + confirmedEnrollments.Count) { diff --git a/RikiPath.Infrastructure/Services/StudyCohortLifecycleWorker.cs b/RikiPath.Infrastructure/Services/StudyCohortLifecycleWorker.cs index b768066f..e5c8c489 100644 --- a/RikiPath.Infrastructure/Services/StudyCohortLifecycleWorker.cs +++ b/RikiPath.Infrastructure/Services/StudyCohortLifecycleWorker.cs @@ -12,16 +12,16 @@ namespace RikiPath.Infrastructure.Services; /// -/// Tự động hóa vòng đời giữ chỗ và tuyển sinh lớp học: -/// 1) Giải phóng giữ chỗ thanh toán đã quá hạn (sau khi đối soát PayOS để không làm mất giao dịch đã trả tiền). -/// 2) Tự động đóng tuyển sinh & hủy các lớp không có học viên khi hết hạn tuyển sinh, giải phóng lịch Giáo viên. -/// 3) Tự động đồng bộ các đề xuất đã phê duyệt chưa tạo lớp (nếu có). +/// Tự động hóa thanh toán giữ chỗ và vòng đời tuyển sinh lớp học. +/// Mỗi lượt chạy đối soát một nhóm giữ chỗ còn hạn với PayOS, kiểm tra giữ chỗ đã hết hạn trước khi giải phóng, +/// rồi đóng tuyển sinh lớp đến hạn hoặc hủy lớp không có học viên. /// public sealed class StudyCohortLifecycleWorker( IServiceScopeFactory scopes, ILogger logger) : BackgroundService { private static readonly TimeSpan CheckInterval = TimeSpan.FromSeconds(30); + private int lastActiveHoldCourseId; protected override async Task ExecuteAsync(CancellationToken stoppingToken) { @@ -44,6 +44,7 @@ private async Task RunPassAsync(CancellationToken ct) var db = scope.ServiceProvider.GetRequiredService(); var nowUtc = DateTime.UtcNow; + await ReconcileActiveSeatHoldsAsync(scope.ServiceProvider, db, nowUtc, ct); await ExpireStaleSeatHoldsAsync(scope.ServiceProvider, db, nowUtc, ct); await ProcessEnrollmentDeadlinesAsync(scope.ServiceProvider, ct); } @@ -57,6 +58,56 @@ private async Task RunPassAsync(CancellationToken ct) } } + private async Task ReconcileActiveSeatHoldsAsync(IServiceProvider sp, AppDbContext db, DateTime nowUtc, CancellationToken ct) + { + // Webhooks can be delayed or unavailable in local development. Check a bounded, rotating + // set of live holds against PayOS so a paid learner is enrolled before the hold expires. + const int batchSize = 12; + var pending = db.StudyCourses.AsNoTracking() + .Where(c => c.CohortId.HasValue && c.Status == "PendingPayment" + && c.PaymentStatus == "Pending" && c.Amount > 0 + && c.PaymentExpiresAt.HasValue && c.PaymentExpiresAt.Value > nowUtc); + var courseIds = await pending.Where(c => c.Id > lastActiveHoldCourseId) + .OrderBy(c => c.Id).Select(c => c.Id).Take(batchSize).ToListAsync(ct); + var nextCursor = courseIds.Count > 0 ? courseIds[^1] : lastActiveHoldCourseId; + if (courseIds.Count < batchSize) + { + var remaining = batchSize - courseIds.Count; + var wrappedIds = await pending.Where(c => c.Id <= lastActiveHoldCourseId) + .OrderBy(c => c.Id).Select(c => c.Id).Take(remaining).ToListAsync(ct); + courseIds.AddRange(wrappedIds); + if (nextCursor == lastActiveHoldCourseId && wrappedIds.Count > 0) + nextCursor = wrappedIds[^1]; + } + if (courseIds.Count == 0) + return; + + lastActiveHoldCourseId = nextCursor; + var paymentClient = sp.GetRequiredService(); + var courses = sp.GetRequiredService(); + foreach (var courseId in courseIds) + { + PaymentLinkInformation info; + try + { + info = await paymentClient.GetPaymentInformationAsync(700_000_000L + courseId, ct); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + logger.LogDebug(ex, "PayOS status check failed for live StudyCourse #{CourseId}.", courseId); + continue; + } + + if (!string.Equals(info.Status?.Trim(), "PAID", StringComparison.OrdinalIgnoreCase)) + continue; + + var result = await courses.ConfirmVerifiedPaymentStatusAsync(courseId, info, ct); + if (!result.IsSuccess) + logger.LogWarning("Verified PayOS payment for StudyCourse #{CourseId} could not be applied: {ErrorCode}", + courseId, result.ErrorCode ?? result.StatusCode.ToString(CultureInfo.InvariantCulture)); + } + } + private async Task ExpireStaleSeatHoldsAsync(IServiceProvider sp, AppDbContext db, DateTime nowUtc, CancellationToken ct) { var expiredCourses = await db.StudyCourses diff --git a/RikiPath.Infrastructure/UnitOfWork.cs b/RikiPath.Infrastructure/UnitOfWork.cs index ff38ac46..5f7e72ed 100644 --- a/RikiPath.Infrastructure/UnitOfWork.cs +++ b/RikiPath.Infrastructure/UnitOfWork.cs @@ -17,6 +17,7 @@ public class UnitOfWork : IUnitOfWork public IGenericRepository CourseScheduleRequests { get; } public IGenericRepository CohortTransferRequests { get; } public IGenericRepository StudyCohortMentorAssignments { get; } + public IGenericRepository StudyCohortMentorInvitations { get; } public IGenericRepository CohortScheduleRequests { get; } public IGenericRepository CohortMentorReviews { get; } public IGenericRepository CohortComplaints { get; } @@ -125,6 +126,7 @@ public UnitOfWork(AppDbContext context) CourseScheduleRequests = new GenericRepository(_context); CohortTransferRequests = new GenericRepository(_context); StudyCohortMentorAssignments = new GenericRepository(_context); + StudyCohortMentorInvitations = new GenericRepository(_context); CohortScheduleRequests = new GenericRepository(_context); CohortMentorReviews = new GenericRepository(_context); CohortComplaints = new GenericRepository(_context); @@ -219,6 +221,8 @@ public async Task SaveChangesAsync(CancellationToken cancellationToken = de return await _context.SaveChangesAsync(cancellationToken); } + public void ClearTrackedEntities() => _context.ChangeTracker.Clear(); + public async Task ExecuteInTransactionAsync( Func operation, CancellationToken cancellationToken = default) diff --git a/RikiPath.WebApi/Controllers/AdminAiConfigurationController.cs b/RikiPath.WebApi/Controllers/AdminAiConfigurationController.cs new file mode 100644 index 00000000..c0127667 --- /dev/null +++ b/RikiPath.WebApi/Controllers/AdminAiConfigurationController.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using RikiPath.Application.IServices; +using RikiPath.Application.Requests.AdminConfig; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.AdminConfig; + +namespace RikiPath.WebApi.Controllers; + +[ApiController] +[Authorize(Roles = "Admin")] +[Route("api/admin/ai-configuration")] +public sealed class AdminAiConfigurationController( + IAdminAiConfigurationService service, IClaimService claims) : ControllerBase +{ + [HttpGet] + [ProducesResponseType(typeof(ApiResponse), 200)] + public async Task Get(CancellationToken ct) + { + var result = await service.GetAsync(ct); + return StatusCode((int)result.StatusCode, result); + } + + [HttpPut] + [ProducesResponseType(typeof(ApiResponse), 200)] + public async Task Update([FromBody] AdminAiConfigurationRequest request, CancellationToken ct) + { + var result = await service.UpdateAsync(request, claims.GetUserClaim().Id, ct); + return StatusCode((int)result.StatusCode, result); + } +} diff --git a/RikiPath.WebApi/Controllers/AdminTeachingProposalController.cs b/RikiPath.WebApi/Controllers/AdminTeachingProposalController.cs index 467be638..9082704f 100644 --- a/RikiPath.WebApi/Controllers/AdminTeachingProposalController.cs +++ b/RikiPath.WebApi/Controllers/AdminTeachingProposalController.cs @@ -50,20 +50,24 @@ public async Task PreviewAttachment(int id, int index, Cancellati } [HttpPost("{id:int}/review")] - public async Task Review(int id, [FromBody] ReviewTeachingProposalRequest request, CancellationToken ct) - => ToActionResult(await service.ReviewProposalAsync(id, request, ct)); + public IActionResult Review(int id, [FromBody] ReviewTeachingProposalRequest request, CancellationToken ct) + => Closed(); [HttpPost("bulk-approve/validate")] - public async Task PrevalidateBulkApprove([FromBody] BulkApproveTeachingProposalsRequest request, CancellationToken ct) - => ToActionResult(await service.PrevalidateBulkApproveAsync(request, ct)); + public IActionResult PrevalidateBulkApprove([FromBody] BulkApproveTeachingProposalsRequest request, CancellationToken ct) + => Closed(); [HttpPost("bulk-approve")] - public async Task BulkApprove([FromBody] BulkApproveTeachingProposalsRequest request, CancellationToken ct) - => ToActionResult(await service.BulkApproveProposalsAsync(request, ct)); + public IActionResult BulkApprove([FromBody] BulkApproveTeachingProposalsRequest request, CancellationToken ct) + => Closed(); [HttpPost("repair-invalid-schedules")] - public async Task RepairInvalidNeedsRevisionSchedules(CancellationToken ct) - => ToActionResult(await service.RepairInvalidNeedsRevisionSchedulesAsync(ct)); + public IActionResult RepairInvalidNeedsRevisionSchedules(CancellationToken ct) + => Closed(); + + private IActionResult Closed() + => Conflict(ApiResponse.Fail("Lịch và lớp nhóm hiện do Admin tạo và mời mentor nhận dạy.", + System.Net.HttpStatusCode.Conflict, "MENTOR_SELF_SCHEDULING_CLOSED")); private IActionResult ToActionResult(ApiResponse response) => StatusCode(response.StatusCode, response); diff --git a/RikiPath.WebApi/Controllers/CohortPreparationZipController.cs b/RikiPath.WebApi/Controllers/CohortPreparationZipController.cs new file mode 100644 index 00000000..0ed8e5d9 --- /dev/null +++ b/RikiPath.WebApi/Controllers/CohortPreparationZipController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using RikiPath.Application.IServices; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.StudyCourses; + +namespace RikiPath.WebApi.Controllers; + +[ApiController] +[Authorize(Roles = "Admin,Mentor,Learner")] +[Route("api/study-courses/cohorts/{cohortId:int}/preparation-zip")] +public sealed class CohortPreparationZipController(ICohortPreparationZipService service) : ControllerBase +{ + [HttpGet] + [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] + public async Task Get(int cohortId, CancellationToken ct) + { + var result = await service.GetAsync(cohortId, ct); + return StatusCode(result.StatusCode, result); + } + + [HttpPut] + [Authorize(Roles = "Admin")] + [Consumes("multipart/form-data")] + [RequestSizeLimit(27 * 1024 * 1024)] + [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] + public async Task Upload(int cohortId, IFormFile? file, CancellationToken ct) + { + if (file is null || !Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase) + || file.Length is <= 0 or > RikiPath.Application.Services.CohortPreparationZipService.MaxZipBytes) + return BadRequest(ApiResponse.Fail("Chọn tệp ZIP hợp lệ, dung lượng tối đa 25 MB.")); + await using var input = file.OpenReadStream(); + await using var buffer = new MemoryStream(); + await input.CopyToAsync(buffer, ct); + buffer.Position = 0; + var result = await service.UploadAsync(cohortId, buffer, ct); + return StatusCode(result.StatusCode, result); + } +} diff --git a/RikiPath.WebApi/Controllers/CohortSessionLearningMaterialsController.cs b/RikiPath.WebApi/Controllers/CohortSessionLearningMaterialsController.cs new file mode 100644 index 00000000..59899b40 --- /dev/null +++ b/RikiPath.WebApi/Controllers/CohortSessionLearningMaterialsController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using RikiPath.Application.IServices; +using RikiPath.Application.Responses; +using RikiPath.Application.Responses.MentorMeetings; + +namespace RikiPath.WebApi.Controllers; + +[ApiController] +[Authorize(Roles = "Admin,Learner,Mentor")] +[Route("api/study-courses/cohorts/{cohortId:int}/sessions/{sessionId:int}/learning-materials")] +public sealed class CohortSessionLearningMaterialsController( + ICohortSessionLearningMaterialsService service) : ControllerBase +{ + [HttpGet] + [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] + public async Task Get(int cohortId, int sessionId, CancellationToken ct) + { + var result = await service.GetAsync(cohortId, sessionId, ct); + return StatusCode(result.StatusCode, result); + } + + [HttpPut, Authorize(Roles = "Mentor")] + [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] + public async Task Prepare(int cohortId, int sessionId, + [FromBody] PrepareCohortSessionLessonsRequest request, CancellationToken ct) + { + var result = await service.PrepareAsync(cohortId, sessionId, request.LessonIds ?? [], ct); + return StatusCode(result.StatusCode, result); + } +} + +public sealed record PrepareCohortSessionLessonsRequest(IReadOnlyList? LessonIds); diff --git a/RikiPath.WebApi/Controllers/MentorTeachingProposalController.cs b/RikiPath.WebApi/Controllers/MentorTeachingProposalController.cs index fb232749..41b166b9 100644 --- a/RikiPath.WebApi/Controllers/MentorTeachingProposalController.cs +++ b/RikiPath.WebApi/Controllers/MentorTeachingProposalController.cs @@ -51,51 +51,55 @@ public async Task PreviewAttachment(int id, int index, Cancellati } [HttpPost("drafts")] - public async Task CreateDraft([FromBody] SaveTeachingProposalDraftRequest request, CancellationToken ct) - => ToActionResult(await service.CreateDraftAsync(request, ct)); + public IActionResult CreateDraft([FromBody] SaveTeachingProposalDraftRequest request, CancellationToken ct) + => Closed(); [HttpPut("{id:int}/draft")] - public async Task UpdateDraft(int id, [FromBody] SaveTeachingProposalDraftRequest request, CancellationToken ct) - => ToActionResult(await service.UpdateDraftAsync(id, request, ct)); + public IActionResult UpdateDraft(int id, [FromBody] SaveTeachingProposalDraftRequest request, CancellationToken ct) + => Closed(); [HttpDelete("{id:int}/draft")] - public async Task DeleteDraft(int id, CancellationToken ct) - => ToActionResult(await service.DeleteDraftAsync(id, ct)); + public IActionResult DeleteDraft(int id, CancellationToken ct) + => Closed(); [HttpPost("validate")] - public async Task Validate([FromBody] ValidateTeachingProposalRequest request, CancellationToken ct) - => ToActionResult(await service.ValidateDraftAsync(request, ct)); + public IActionResult Validate([FromBody] ValidateTeachingProposalRequest request, CancellationToken ct) + => Closed(); [HttpPost("{id:int}/submit")] [EnableRateLimiting("mentor-availability-submit")] - public async Task Submit(int id, [FromBody] SubmitTeachingProposalRequest request, CancellationToken ct) - => ToActionResult(await service.SubmitProposalAsync(id, request, ct)); + public IActionResult Submit(int id, [FromBody] SubmitTeachingProposalRequest request, CancellationToken ct) + => Closed(); [HttpPost("{id:int}/resubmit")] [EnableRateLimiting("mentor-availability-submit")] - public async Task Resubmit(int id, [FromBody] ResubmitTeachingProposalRequest request, CancellationToken ct) - => ToActionResult(await service.ResubmitProposalAsync(id, request, ct)); + public IActionResult Resubmit(int id, [FromBody] ResubmitTeachingProposalRequest request, CancellationToken ct) + => Closed(); [HttpPost("{id:int}/withdraw")] - public async Task Withdraw(int id, [FromBody] WithdrawTeachingProposalRequest? request, CancellationToken ct) - => ToActionResult(await service.WithdrawProposalAsync(id, request, ct)); + public IActionResult Withdraw(int id, [FromBody] WithdrawTeachingProposalRequest? request, CancellationToken ct) + => Closed(); [HttpPost("{id:int}/open-enrollment/preview")] - public async Task PreviewOpenEnrollment(int id, [FromBody] OpenEnrollmentPreviewRequest? request, CancellationToken ct) - => ToActionResult(await service.PreviewOpenEnrollmentAsync(id, request, ct)); + public IActionResult PreviewOpenEnrollment(int id, [FromBody] OpenEnrollmentPreviewRequest? request, CancellationToken ct) + => Closed(); [HttpPost("{id:int}/open-enrollment")] [EnableRateLimiting("mentor-availability-submit")] - public async Task ConfirmOpenEnrollment(int id, [FromBody] ConfirmOpenEnrollmentRequest request, CancellationToken ct) - => ToActionResult(await service.ConfirmOpenEnrollmentAsync(id, request, ct)); + public IActionResult ConfirmOpenEnrollment(int id, [FromBody] ConfirmOpenEnrollmentRequest request, CancellationToken ct) + => Closed(); [HttpDelete("{id:int}/history")] public async Task HideRejectedHistory(int id, CancellationToken ct) => ToActionResult(await service.HideRejectedProposalAsync(id, ct)); [HttpPost("{id:int}/clone-draft")] - public async Task CloneToDraft(int id, CancellationToken ct) - => ToActionResult(await service.ReopenForRevisionAsync(id, ct)); + public IActionResult CloneToDraft(int id, CancellationToken ct) + => Closed(); + + private IActionResult Closed() + => Conflict(ApiResponse.Fail("Lịch và lớp nhóm hiện do Admin tạo và mời mentor nhận dạy.", + System.Net.HttpStatusCode.Conflict, "MENTOR_SELF_SCHEDULING_CLOSED")); private IActionResult ToActionResult(ApiResponse response) => StatusCode(response.StatusCode, response); diff --git a/RikiPath.WebApi/Controllers/StudyCoursesController.cs b/RikiPath.WebApi/Controllers/StudyCoursesController.cs index d278982a..7144279f 100644 --- a/RikiPath.WebApi/Controllers/StudyCoursesController.cs +++ b/RikiPath.WebApi/Controllers/StudyCoursesController.cs @@ -98,7 +98,29 @@ private static bool TryParseLocalTime(string? value, out TimeOnly? time) [HttpGet("my-entitlements"), Authorize(Roles = "Learner")] public async Task MyEntitlements(CancellationToken ct) => Result(await entitlements.MyEntitlementsAsync(ct)); [HttpPost("cohorts"), Authorize(Roles = "Admin")] - public async Task CreateCohort(SaveStudyCohort r, CancellationToken ct) => Result(await service.SaveCohortAsync(null, r, ct)); + public async Task CreateCohort(CreateAdminCohortRequest r, CancellationToken ct) + => Result(await service.CreateAdminCohortAsync(r, ct)); + [HttpPost("cohorts/mentor-candidates"), Authorize(Roles = "Admin")] + public async Task CohortMentorCandidates(AdminCohortMentorCandidatesRequest r, CancellationToken ct) + => Result(await service.AdminCohortMentorCandidatesAsync(r, ct)); + [HttpGet("cohort-mentor-invitations"), Authorize(Roles = "Admin,Mentor")] + public async Task CohortMentorInvitations([FromQuery] int? cohortId, CancellationToken ct) + => Result(await service.CohortMentorInvitationsAsync(cohortId, ct)); + [HttpPost("cohorts/{cohortId:int}/mentor-invitations"), Authorize(Roles = "Admin")] + public async Task InviteCohortMentor(int cohortId, InviteCohortMentorRequest r, CancellationToken ct) + => Result(await service.InviteCohortMentorAsync(cohortId, r, ct)); + [HttpPost("cohort-mentor-invitations/{invitationId:int}/accept"), Authorize(Roles = "Mentor")] + public async Task AcceptCohortMentorInvitation(int invitationId, CancellationToken ct) + => Result(await service.AcceptCohortMentorInvitationAsync(invitationId, ct)); + [HttpPost("cohort-mentor-invitations/{invitationId:int}/decline"), Authorize(Roles = "Mentor")] + public async Task DeclineCohortMentorInvitation(int invitationId, DeclineCohortInvitationRequest r, CancellationToken ct) + => Result(await service.DeclineCohortMentorInvitationAsync(invitationId, r, ct)); + [HttpPost("cohort-mentor-invitations/{invitationId:int}/cancel"), Authorize(Roles = "Admin")] + public async Task CancelCohortMentorInvitation(int invitationId, CancellationToken ct) + => Result(await service.CancelCohortMentorInvitationAsync(invitationId, ct)); + [HttpPost("cohorts/{cohortId:int}/mentor-change-requests"), Authorize(Roles = "Mentor")] + public async Task RequestCohortMentorChange(int cohortId, RequestCohortMentorChangeRequest r, CancellationToken ct) + => Result(await service.RequestCohortMentorChangeAsync(cohortId, r, ct)); /// /// Admin xem trước xung đột lịch dạy của Mentor (trùng giờ, thời gian nghỉ, giới hạn ngày/tuần) cho các khung giờ đã chọn. /// Chỉ mang tính tham khảo; khi lưu/công bố lớp hệ thống vẫn kiểm tra lại trong giao dịch. @@ -235,11 +257,11 @@ public async Task TransferEvidence(int requestId, [FromQuery] boo return ProposalAttachmentStreamHelper.StreamPrivateVerificationResult( this, file, $"minh-chung-chuyen-lop-{requestId}", download); } - /// Xem trước tác động khi thay cố vấn chính cho các buổi còn lại của lớp. + /// Xem trước điều kiện thay mentor cho các buổi còn lại của lớp. [HttpGet("cohorts/{cohortId:int}/mentor-replacement/preview"), Authorize(Roles = "Admin")] public async Task PreviewMentorReplacement(int cohortId, [FromQuery] int mentorId, [FromQuery] int? fromSessionNumber, CancellationToken ct) => Result(await service.PreviewMentorReplacementAsync(cohortId, mentorId, fromSessionNumber, ct)); - /// Admin xác nhận thay cố vấn chính; buổi đã diễn ra giữ cố vấn thực dạy. + /// Admin gửi lời mời mentor mới; mentor xác nhận trước khi thay các buổi còn lại. [HttpPost("cohorts/{cohortId:int}/mentor-replacement"), Authorize(Roles = "Admin")] public async Task ReplaceCohortMentor(int cohortId, ReplaceCohortMentorRequest r, CancellationToken ct) => Result(await service.ReplaceCohortMentorAsync(cohortId, r, ct)); diff --git a/RikiPath.WebApi/Program.cs b/RikiPath.WebApi/Program.cs index 72b0e876..f6d3512e 100644 --- a/RikiPath.WebApi/Program.cs +++ b/RikiPath.WebApi/Program.cs @@ -171,7 +171,8 @@ private static void Main(string[] args) builder.Services.AddHttpClient(); builder.Services.AddHttpClient(); var calendarProtection = builder.Services.AddDataProtection().SetApplicationName("RikiPath.MentorCalendar"); - var calendarKeysPath = builder.Configuration["GoogleCalendar:DataProtectionKeysPath"]; + var calendarKeysPath = builder.Configuration["GoogleCalendar:DataProtectionKeysPath"] + ?? builder.Configuration["AiConfiguration:DataProtectionKeysPath"]; if (!string.IsNullOrWhiteSpace(calendarKeysPath)) calendarProtection.PersistKeysToFileSystem(new DirectoryInfo(calendarKeysPath)); builder.Services.AddHttpClient("MentorCalendar", c => c.Timeout = TimeSpan.FromSeconds(15)); builder.Services.AddScoped(); diff --git a/tools/verify-migration-readiness.ps1 b/tools/verify-migration-readiness.ps1 index b2a55acd..972c779a 100644 --- a/tools/verify-migration-readiness.ps1 +++ b/tools/verify-migration-readiness.ps1 @@ -11,7 +11,7 @@ 4. "__EFMigrationsHistory" divergence (pending canonical migrations, missing-source IDs, audited cross-branch IDs vs unexpected unknown IDs). 5. Live database readiness checks (btree_gist, MentorReviews, Group Learning base tables, - active cohort duplicate conflicts, invalid credit/compensation FKs). + invitation revision column, active cohort duplicate conflicts, invalid credit/compensation FKs). NEVER executes DDL, DML, CREATE EXTENSION, or `dotnet ef database update`. #> @@ -240,6 +240,24 @@ SELECT if (-not $feedbackParity) { Write-Warning 'Audited AddLearnerFeedback history ID does not match expected schema/RLS.' } } + $invitationRevisionReady = $true + if ('20261201081546_AddAdminCohortMentorInvitations' -in $applied) { + $invitationRevisionReady = (Invoke-ReadOnlySql @' +SELECT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'StudyCohortMentorInvitations' + AND column_name = 'CohortRevisionAtInvite' + AND data_type = 'integer' + AND is_nullable = 'NO' +)::text +'@ | Select-Object -First 1) -eq 'true' + Write-Host (" Invitation revision ready : {0}" -f $invitationRevisionReady) + if (-not $invitationRevisionReady) { + Write-Warning 'AddAdminCohortMentorInvitations is marked applied, but its required revision column is missing or incompatible.' + } + } + $checks = Invoke-ReadOnlySql @' SELECT (SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'btree_gist'))::text, @@ -278,7 +296,7 @@ SELECT $presentCount = [int]($presentTables | Select-Object -First 1) Write-Host (" Reconciled tables present : {0}/{1}" -f $presentCount, $reconciledTables.Count) - if ($unexpectedExtra.Count -gt 0 -or $pending.Count -gt 0 -or -not $feedbackParity -or + if ($unexpectedExtra.Count -gt 0 -or $pending.Count -gt 0 -or -not $feedbackParity -or -not $invitationRevisionReady -or $partsOut[0] -ne 'true' -or $partsOut[1] -ne 'true' -or $partsOut[2] -ne 'true' -or $partsOut[3] -ne 'true' -or [int]$partsOut[4] -gt 0 -or [int]$partsOut[5] -gt 0 -or [int]$partsOut[6] -gt 0 -or