feat: add vocabulary and handbook persistence
This commit is contained in:
@@ -0,0 +1,336 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Tiku.Domain.Catalog;
|
||||
using Tiku.Domain.Content;
|
||||
using Tiku.Domain.Identity;
|
||||
|
||||
namespace Tiku.Infrastructure.Persistence.Configurations;
|
||||
|
||||
internal sealed class VocabularyUnitConfiguration : IEntityTypeConfiguration<VocabularyUnit>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<VocabularyUnit> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("vocabulary_units");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Name).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Description).HasMaxLength(2000);
|
||||
builder.Property(entity => entity.SourceHash).HasMaxLength(128);
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.EntryId,
|
||||
entity.ContentNodeId,
|
||||
entity.RegionId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
|
||||
builder.HasOne<Region>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.RegionId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentEntry>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentNode>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class VocabularyWordConfiguration : IEntityTypeConfiguration<VocabularyWord>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<VocabularyWord> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("vocabulary_words");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Word).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Phonetic).HasMaxLength(200);
|
||||
builder.Property(entity => entity.Meaning).HasMaxLength(2000);
|
||||
builder.Property(entity => entity.Example).HasMaxLength(4000);
|
||||
builder.Property(entity => entity.ExampleTranslation).HasMaxLength(4000);
|
||||
builder.Property(entity => entity.SourceHash).HasMaxLength(128);
|
||||
builder.Property(entity => entity.Tags).IsJson("[]");
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.EntryId,
|
||||
entity.ContentNodeId,
|
||||
entity.UnitId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.UnitId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder,
|
||||
entity.CreatedAt
|
||||
});
|
||||
|
||||
builder.HasOne<VocabularyUnit>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.UnitId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentEntry>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentNode>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class UserWordProgressConfiguration : IEntityTypeConfiguration<UserWordProgress>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserWordProgress> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("user_word_progress");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacyUserId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacyWordId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Status).HasSnakeCaseEnum();
|
||||
builder.Property(entity => entity.EaseFactor).HasPrecision(4, 2).HasDefaultValue(2.50m);
|
||||
builder.Property(entity => entity.LastResult).HasNullableSnakeCaseEnum();
|
||||
builder.Property(entity => entity.DueLevel).HasSnakeCaseEnum();
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.WordId }).IsUnique();
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.Status });
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.UserId,
|
||||
entity.NextReviewAt,
|
||||
entity.Status,
|
||||
entity.DueLevel
|
||||
});
|
||||
|
||||
builder.ToTable(table =>
|
||||
{
|
||||
table.HasCheckConstraint("ck_user_word_progress_review_count", "review_count >= 0");
|
||||
table.HasCheckConstraint("ck_user_word_progress_correct_streak", "correct_streak >= 0");
|
||||
table.HasCheckConstraint("ck_user_word_progress_ease_factor", "ease_factor >= 1.30 and ease_factor <= 3.00");
|
||||
});
|
||||
|
||||
builder.HasOne<User>().WithMany()
|
||||
.HasForeignKey(entity => entity.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<VocabularyWord>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.WordId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class UserWordFavoriteConfiguration : IEntityTypeConfiguration<UserWordFavorite>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserWordFavorite> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("user_word_favorites");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacyUserId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacyWordId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Note).HasMaxLength(2000);
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.WordId }).IsUnique();
|
||||
|
||||
builder.HasOne<User>().WithMany()
|
||||
.HasForeignKey(entity => entity.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<VocabularyWord>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.WordId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HandbookSubjectConfiguration : IEntityTypeConfiguration<HandbookSubject>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<HandbookSubject> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("handbook_subjects");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Name).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Type).HasNullableSnakeCaseEnum();
|
||||
builder.Property(entity => entity.Icon).HasMaxLength(2048);
|
||||
builder.Property(entity => entity.Color).HasMaxLength(50);
|
||||
builder.Property(entity => entity.Description).HasMaxLength(2000);
|
||||
builder.Property(entity => entity.MajorLegacyIds).IsJson("[]");
|
||||
builder.Property(entity => entity.SourceHash).HasMaxLength(128);
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.EntryId,
|
||||
entity.ContentNodeId,
|
||||
entity.RegionId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
|
||||
builder.HasOne<Region>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.RegionId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<School>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.SchoolId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<Major>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.MajorId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentEntry>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentNode>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HandbookChapterConfiguration : IEntityTypeConfiguration<HandbookChapter>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<HandbookChapter> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("handbook_chapters");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Name).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Description).HasMaxLength(2000);
|
||||
builder.Property(entity => entity.SourceHash).HasMaxLength(128);
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.EntryId,
|
||||
entity.ContentNodeId,
|
||||
entity.SubjectId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
|
||||
builder.HasOne<HandbookSubject>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.SubjectId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<ContentEntry>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentNode>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HandbookEntryConfiguration : IEntityTypeConfiguration<HandbookEntry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<HandbookEntry> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("handbook_entries");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.Title).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Summary).HasMaxLength(2000);
|
||||
builder.Property(entity => entity.Tags).IsJson("[]");
|
||||
builder.Property(entity => entity.SourceHash).HasMaxLength(128);
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.EntryId,
|
||||
entity.ContentNodeId,
|
||||
entity.ChapterId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
|
||||
builder.HasOne<HandbookChapter>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ChapterId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<ContentEntry>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne<ContentNode>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class QuestionTypeGroupConfiguration : IEntityTypeConfiguration<QuestionTypeGroup>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<QuestionTypeGroup> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("question_type_groups");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.DisplayName).HasMaxLength(300);
|
||||
builder.Property(entity => entity.Types).IsJson("[]");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.SubjectId,
|
||||
entity.IsActive,
|
||||
entity.SortOrder
|
||||
});
|
||||
|
||||
builder.HasOne<Subject>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.SubjectId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SubjectShareConfiguration : IEntityTypeConfiguration<SubjectShare>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SubjectShare> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("subject_shares");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.LegacyId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacySourceSubjectId).HasMaxLength(64);
|
||||
builder.Property(entity => entity.LegacyTargetSubjectId).HasMaxLength(64);
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
|
||||
builder.HasIndex(entity => new
|
||||
{
|
||||
entity.TenantId,
|
||||
entity.SourceSubjectId,
|
||||
entity.TargetSubjectId
|
||||
}).IsUnique();
|
||||
|
||||
builder.HasOne<Subject>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.SourceSubjectId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<Subject>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.TargetSubjectId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
4505
Tiku.Infrastructure/Persistence/Migrations/20260725210815_AddVocabularyAndHandbookPersistence.Designer.cs
generated
Normal file
4505
Tiku.Infrastructure/Persistence/Migrations/20260725210815_AddVocabularyAndHandbookPersistence.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,648 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddVocabularyAndHandbookPersistence : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "handbook_subjects",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
region_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
school_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
major_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
entry_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
content_node_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
|
||||
type = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
icon = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
||||
color = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
||||
description = table.Column<string>(type: "text", nullable: true),
|
||||
major_legacy_ids = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
source_hash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_handbook_subjects", x => x.id);
|
||||
table.UniqueConstraint("ak_handbook_subjects_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_content_entries_tenant_id_entry_id",
|
||||
columns: x => new { x.tenant_id, x.entry_id },
|
||||
principalTable: "content_entries",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_content_nodes_tenant_id_content_node_id",
|
||||
columns: x => new { x.tenant_id, x.content_node_id },
|
||||
principalTable: "content_nodes",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_majors_tenant_id_major_id",
|
||||
columns: x => new { x.tenant_id, x.major_id },
|
||||
principalTable: "majors",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_regions_tenant_id_region_id",
|
||||
columns: x => new { x.tenant_id, x.region_id },
|
||||
principalTable: "regions",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_schools_tenant_id_school_id",
|
||||
columns: x => new { x.tenant_id, x.school_id },
|
||||
principalTable: "schools",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_subjects_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "question_type_groups",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
subject_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
display_name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||
types = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_question_type_groups", x => x.id);
|
||||
table.UniqueConstraint("ak_question_type_groups_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_question_type_groups_subjects_tenant_id_subject_id",
|
||||
columns: x => new { x.tenant_id, x.subject_id },
|
||||
principalTable: "subjects",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_question_type_groups_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "subject_shares",
|
||||
columns: table => new
|
||||
{
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
source_subject_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
target_subject_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
legacy_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_source_subject_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_target_subject_id = table.Column<string>(type: "text", nullable: true),
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_subject_shares", x => new { x.tenant_id, x.source_subject_id, x.target_subject_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_subject_shares_subjects_tenant_id_source_subject_id",
|
||||
columns: x => new { x.tenant_id, x.source_subject_id },
|
||||
principalTable: "subjects",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_subject_shares_subjects_tenant_id_target_subject_id",
|
||||
columns: x => new { x.tenant_id, x.target_subject_id },
|
||||
principalTable: "subjects",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_subject_shares_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "vocabulary_units",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
region_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
entry_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
content_node_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
|
||||
description = table.Column<string>(type: "text", nullable: true),
|
||||
word_count = table.Column<int>(type: "integer", nullable: true),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
source_hash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_vocabulary_units", x => x.id);
|
||||
table.UniqueConstraint("ak_vocabulary_units_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_units_content_entries_tenant_id_entry_id",
|
||||
columns: x => new { x.tenant_id, x.entry_id },
|
||||
principalTable: "content_entries",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_units_content_nodes_tenant_id_content_node_id",
|
||||
columns: x => new { x.tenant_id, x.content_node_id },
|
||||
principalTable: "content_nodes",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_units_regions_tenant_id_region_id",
|
||||
columns: x => new { x.tenant_id, x.region_id },
|
||||
principalTable: "regions",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_units_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "handbook_chapters",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
subject_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
entry_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
content_node_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
name = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
|
||||
description = table.Column<string>(type: "text", nullable: true),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
source_hash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_handbook_chapters", x => x.id);
|
||||
table.UniqueConstraint("ak_handbook_chapters_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_chapters_content_entries_tenant_id_entry_id",
|
||||
columns: x => new { x.tenant_id, x.entry_id },
|
||||
principalTable: "content_entries",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_chapters_content_nodes_tenant_id_content_node_id",
|
||||
columns: x => new { x.tenant_id, x.content_node_id },
|
||||
principalTable: "content_nodes",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_chapters_handbook_subjects_tenant_id_subject_id",
|
||||
columns: x => new { x.tenant_id, x.subject_id },
|
||||
principalTable: "handbook_subjects",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_chapters_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "vocabulary_words",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
unit_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
entry_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
content_node_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
word = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
|
||||
phonetic = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: true),
|
||||
meaning = table.Column<string>(type: "text", nullable: true),
|
||||
example = table.Column<string>(type: "text", nullable: true),
|
||||
example_translation = table.Column<string>(type: "text", nullable: true),
|
||||
difficulty = table.Column<int>(type: "integer", nullable: true),
|
||||
tags = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
source_hash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_vocabulary_words", x => x.id);
|
||||
table.UniqueConstraint("ak_vocabulary_words_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_words_content_entries_tenant_id_entry_id",
|
||||
columns: x => new { x.tenant_id, x.entry_id },
|
||||
principalTable: "content_entries",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_words_content_nodes_tenant_id_content_node_id",
|
||||
columns: x => new { x.tenant_id, x.content_node_id },
|
||||
principalTable: "content_nodes",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_words_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_vocabulary_words_vocabulary_units_tenant_id_unit_id",
|
||||
columns: x => new { x.tenant_id, x.unit_id },
|
||||
principalTable: "vocabulary_units",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "handbook_entries",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
chapter_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
entry_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
content_node_id = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
legacy_id = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
title = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
|
||||
summary = table.Column<string>(type: "text", nullable: true),
|
||||
content = table.Column<string>(type: "text", nullable: true),
|
||||
tags = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
|
||||
sort_order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||
source_hash = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_handbook_entries", x => x.id);
|
||||
table.UniqueConstraint("ak_handbook_entries_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_entries_content_entries_tenant_id_entry_id",
|
||||
columns: x => new { x.tenant_id, x.entry_id },
|
||||
principalTable: "content_entries",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_entries_content_nodes_tenant_id_content_node_id",
|
||||
columns: x => new { x.tenant_id, x.content_node_id },
|
||||
principalTable: "content_nodes",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_entries_handbook_chapters_tenant_id_chapter_id",
|
||||
columns: x => new { x.tenant_id, x.chapter_id },
|
||||
principalTable: "handbook_chapters",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_handbook_entries_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "user_word_favorites",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
word_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
legacy_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_user_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_word_id = table.Column<string>(type: "text", nullable: true),
|
||||
note = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||||
favorited_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_user_word_favorites", x => x.id);
|
||||
table.UniqueConstraint("ak_user_word_favorites_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_favorites_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_favorites_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_favorites_vocabulary_words_tenant_id_word_id",
|
||||
columns: x => new { x.tenant_id, x.word_id },
|
||||
principalTable: "vocabulary_words",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "user_word_progress",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
word_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
legacy_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_user_id = table.Column<string>(type: "text", nullable: true),
|
||||
legacy_word_id = table.Column<string>(type: "text", nullable: true),
|
||||
status = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||
correct_count = table.Column<int>(type: "integer", nullable: false),
|
||||
wrong_count = table.Column<int>(type: "integer", nullable: false),
|
||||
last_review_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
next_review_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
review_count = table.Column<int>(type: "integer", nullable: false),
|
||||
correct_streak = table.Column<int>(type: "integer", nullable: false),
|
||||
ease_factor = table.Column<decimal>(type: "numeric(4,2)", precision: 4, scale: 2, nullable: false, defaultValue: 2.50m),
|
||||
last_result = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
due_level = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||
metadata = table.Column<JsonElement>(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
|
||||
tenant_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
updated_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_user_word_progress", x => x.id);
|
||||
table.UniqueConstraint("ak_user_word_progress_tenant_id_id", x => new { x.tenant_id, x.id });
|
||||
table.CheckConstraint("ck_user_word_progress_correct_streak", "correct_streak >= 0");
|
||||
table.CheckConstraint("ck_user_word_progress_ease_factor", "ease_factor >= 1.30 and ease_factor <= 3.00");
|
||||
table.CheckConstraint("ck_user_word_progress_review_count", "review_count >= 0");
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_progress_tenants_tenant_id",
|
||||
column: x => x.tenant_id,
|
||||
principalTable: "tenants",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_progress_users_user_id",
|
||||
column: x => x.user_id,
|
||||
principalTable: "users",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_user_word_progress_vocabulary_words_tenant_id_word_id",
|
||||
columns: x => new { x.tenant_id, x.word_id },
|
||||
principalTable: "vocabulary_words",
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_chapters_tenant_id_content_node_id",
|
||||
table: "handbook_chapters",
|
||||
columns: new[] { "tenant_id", "content_node_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_chapters_tenant_id_entry_id_content_node_id_subjec~",
|
||||
table: "handbook_chapters",
|
||||
columns: new[] { "tenant_id", "entry_id", "content_node_id", "subject_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_chapters_tenant_id_legacy_id",
|
||||
table: "handbook_chapters",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_chapters_tenant_id_subject_id",
|
||||
table: "handbook_chapters",
|
||||
columns: new[] { "tenant_id", "subject_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_entries_tenant_id_chapter_id",
|
||||
table: "handbook_entries",
|
||||
columns: new[] { "tenant_id", "chapter_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_entries_tenant_id_content_node_id",
|
||||
table: "handbook_entries",
|
||||
columns: new[] { "tenant_id", "content_node_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_entries_tenant_id_entry_id_content_node_id_chapter~",
|
||||
table: "handbook_entries",
|
||||
columns: new[] { "tenant_id", "entry_id", "content_node_id", "chapter_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_entries_tenant_id_legacy_id",
|
||||
table: "handbook_entries",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_content_node_id",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "content_node_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_entry_id_content_node_id_region~",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "entry_id", "content_node_id", "region_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_legacy_id",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_major_id",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "major_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_region_id",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "region_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_handbook_subjects_tenant_id_school_id",
|
||||
table: "handbook_subjects",
|
||||
columns: new[] { "tenant_id", "school_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_question_type_groups_tenant_id_legacy_id",
|
||||
table: "question_type_groups",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_question_type_groups_tenant_id_subject_id_is_active_sort_or~",
|
||||
table: "question_type_groups",
|
||||
columns: new[] { "tenant_id", "subject_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_subject_shares_tenant_id_target_subject_id",
|
||||
table: "subject_shares",
|
||||
columns: new[] { "tenant_id", "target_subject_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_favorites_tenant_id_user_id_word_id",
|
||||
table: "user_word_favorites",
|
||||
columns: new[] { "tenant_id", "user_id", "word_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_favorites_tenant_id_word_id",
|
||||
table: "user_word_favorites",
|
||||
columns: new[] { "tenant_id", "word_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_favorites_user_id",
|
||||
table: "user_word_favorites",
|
||||
column: "user_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_progress_tenant_id_user_id_next_review_at_status_~",
|
||||
table: "user_word_progress",
|
||||
columns: new[] { "tenant_id", "user_id", "next_review_at", "status", "due_level" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_progress_tenant_id_user_id_word_id",
|
||||
table: "user_word_progress",
|
||||
columns: new[] { "tenant_id", "user_id", "word_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_progress_tenant_id_word_id",
|
||||
table: "user_word_progress",
|
||||
columns: new[] { "tenant_id", "word_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_user_word_progress_user_id",
|
||||
table: "user_word_progress",
|
||||
column: "user_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_units_tenant_id_content_node_id",
|
||||
table: "vocabulary_units",
|
||||
columns: new[] { "tenant_id", "content_node_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_units_tenant_id_entry_id_content_node_id_region_~",
|
||||
table: "vocabulary_units",
|
||||
columns: new[] { "tenant_id", "entry_id", "content_node_id", "region_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_units_tenant_id_legacy_id",
|
||||
table: "vocabulary_units",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_units_tenant_id_region_id",
|
||||
table: "vocabulary_units",
|
||||
columns: new[] { "tenant_id", "region_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_words_tenant_id_content_node_id",
|
||||
table: "vocabulary_words",
|
||||
columns: new[] { "tenant_id", "content_node_id" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_words_tenant_id_entry_id_content_node_id_unit_id~",
|
||||
table: "vocabulary_words",
|
||||
columns: new[] { "tenant_id", "entry_id", "content_node_id", "unit_id", "is_active", "sort_order" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_words_tenant_id_legacy_id",
|
||||
table: "vocabulary_words",
|
||||
columns: new[] { "tenant_id", "legacy_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_vocabulary_words_tenant_id_unit_id_is_active_sort_order_cre~",
|
||||
table: "vocabulary_words",
|
||||
columns: new[] { "tenant_id", "unit_id", "is_active", "sort_order", "created_at" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "handbook_entries");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "question_type_groups");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "subject_shares");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "user_word_favorites");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "user_word_progress");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "handbook_chapters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "vocabulary_words");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "handbook_subjects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "vocabulary_units");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,15 @@ public sealed class TikuDbContext(DbContextOptions<TikuDbContext> options) : DbC
|
||||
public DbSet<QuestionCollection> QuestionCollections => Set<QuestionCollection>();
|
||||
public DbSet<QuestionCollectionItem> QuestionCollectionItems => Set<QuestionCollectionItem>();
|
||||
public DbSet<PracticeBlueprint> PracticeBlueprints => Set<PracticeBlueprint>();
|
||||
public DbSet<VocabularyUnit> VocabularyUnits => Set<VocabularyUnit>();
|
||||
public DbSet<VocabularyWord> VocabularyWords => Set<VocabularyWord>();
|
||||
public DbSet<UserWordProgress> UserWordProgress => Set<UserWordProgress>();
|
||||
public DbSet<UserWordFavorite> UserWordFavorites => Set<UserWordFavorite>();
|
||||
public DbSet<HandbookSubject> HandbookSubjects => Set<HandbookSubject>();
|
||||
public DbSet<HandbookChapter> HandbookChapters => Set<HandbookChapter>();
|
||||
public DbSet<HandbookEntry> HandbookEntries => Set<HandbookEntry>();
|
||||
public DbSet<QuestionTypeGroup> QuestionTypeGroups => Set<QuestionTypeGroup>();
|
||||
public DbSet<SubjectShare> SubjectShares => Set<SubjectShare>();
|
||||
public DbSet<PracticeSession> PracticeSessions => Set<PracticeSession>();
|
||||
public DbSet<AnswerRecord> AnswerRecords => Set<AnswerRecord>();
|
||||
public DbSet<FavoriteQuestion> FavoriteQuestions => Set<FavoriteQuestion>();
|
||||
|
||||
Reference in New Issue
Block a user