using System;
using System.Text.Json;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Tiku.Infrastructure.Persistence.Migrations
{
///
public partial class AddContentAssetsAndImportPersistence : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "app_assets",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
legacy_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
asset_key = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
file_name = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
metadata = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_app_assets", x => x.id);
table.UniqueConstraint("ak_app_assets_tenant_id_id", x => new { x.tenant_id, x.id });
table.ForeignKey(
name: "fk_app_assets_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "content_assets",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
region_id = table.Column(type: "uuid", nullable: true),
subject_id = table.Column(type: "uuid", nullable: true),
category_id = table.Column(type: "uuid", nullable: true),
content_node_id = table.Column(type: "uuid", nullable: true),
created_by = table.Column(type: "uuid", nullable: true),
updated_by = table.Column(type: "uuid", nullable: true),
verified_by = table.Column(type: "uuid", nullable: true),
legacy_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
asset_key = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
title = table.Column(type: "character varying(300)", maxLength: 300, nullable: true),
category = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
description = table.Column(type: "text", nullable: true),
file_name = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
cdn_url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
is_public = table.Column(type: "boolean", nullable: false),
asset_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
storage_provider = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
bucket = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
object_key = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
mime_type = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
file_size_bytes = table.Column(type: "bigint", nullable: true),
checksum_sha256 = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
visibility = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
preview_url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
sort_order = table.Column(type: "integer", nullable: false),
access_rules = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
source = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
download_count = table.Column(type: "integer", nullable: false),
upload_status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
verified_at = table.Column(type: "timestamp with time zone", nullable: true),
verified_size_bytes = table.Column(type: "bigint", nullable: true),
verified_checksum_sha256 = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
verification_details = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
preview_object_key = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true),
preview_status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
security_flags = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
metadata = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_content_assets", x => x.id);
table.UniqueConstraint("ak_content_assets_tenant_id_id", x => new { x.tenant_id, x.id });
table.CheckConstraint("ck_content_assets_download_count", "download_count >= 0");
table.CheckConstraint("ck_content_assets_file_size", "file_size_bytes is null or file_size_bytes >= 0");
table.CheckConstraint("ck_content_assets_verified_checksum", "verified_checksum_sha256 is null or verified_checksum_sha256 ~ '^[a-f0-9]{64}$'");
table.CheckConstraint("ck_content_assets_verified_size", "verified_size_bytes is null or verified_size_bytes >= 0");
table.ForeignKey(
name: "fk_content_assets_categories_tenant_id_category_id",
columns: x => new { x.tenant_id, x.category_id },
principalTable: "categories",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_assets_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_content_assets_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_content_assets_subjects_tenant_id_subject_id",
columns: x => new { x.tenant_id, x.subject_id },
principalTable: "subjects",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_assets_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_content_assets_users_created_by",
column: x => x.created_by,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "fk_content_assets_users_updated_by",
column: x => x.updated_by,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "fk_content_assets_users_verified_by",
column: x => x.verified_by,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "content_import_jobs",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
created_by = table.Column(type: "uuid", nullable: true),
target_region_id = table.Column(type: "uuid", nullable: true),
target_subject_id = table.Column(type: "uuid", nullable: true),
target_category_id = table.Column(type: "uuid", nullable: true),
target_content_node_id = table.Column(type: "uuid", nullable: true),
target_question_bank_id = table.Column(type: "uuid", nullable: true),
import_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
source_format = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
source_name = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
source_hash = table.Column(type: "character varying(128)", maxLength: 128, nullable: true),
dry_run = table.Column(type: "boolean", nullable: false),
total_count = table.Column(type: "integer", nullable: false),
valid_count = table.Column(type: "integer", nullable: false),
error_count = table.Column(type: "integer", nullable: false),
warning_count = table.Column(type: "integer", nullable: false),
inserted_count = table.Column(type: "integer", nullable: false),
updated_count = table.Column(type: "integer", nullable: false),
skipped_count = table.Column(type: "integer", nullable: false),
summary = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
raw_payload = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
normalized_payload = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
error_message = table.Column(type: "text", nullable: true),
started_at = table.Column(type: "timestamp with time zone", nullable: true),
finished_at = table.Column(type: "timestamp with time zone", nullable: true),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_content_import_jobs", x => x.id);
table.UniqueConstraint("ak_content_import_jobs_tenant_id_id", x => new { x.tenant_id, x.id });
table.CheckConstraint("ck_content_import_jobs_counts", "total_count >= 0 and valid_count >= 0 and error_count >= 0 and warning_count >= 0 and inserted_count >= 0 and updated_count >= 0 and skipped_count >= 0");
table.ForeignKey(
name: "fk_content_import_jobs_categories_tenant_id_target_category_id",
columns: x => new { x.tenant_id, x.target_category_id },
principalTable: "categories",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_import_jobs_content_nodes_tenant_id_target_content_~",
columns: x => new { x.tenant_id, x.target_content_node_id },
principalTable: "content_nodes",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_import_jobs_question_banks_tenant_id_target_questio~",
columns: x => new { x.tenant_id, x.target_question_bank_id },
principalTable: "question_banks",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_import_jobs_regions_tenant_id_target_region_id",
columns: x => new { x.tenant_id, x.target_region_id },
principalTable: "regions",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_content_import_jobs_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.Restrict);
table.ForeignKey(
name: "fk_content_import_jobs_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_content_import_jobs_users_created_by",
column: x => x.created_by,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "images",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
legacy_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
title = table.Column(type: "character varying(300)", maxLength: 300, nullable: true),
category = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
file_name = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
is_public = table.Column(type: "boolean", nullable: false),
cdn_url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
metadata = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_images", x => x.id);
table.UniqueConstraint("ak_images_tenant_id_id", x => new { x.tenant_id, x.id });
table.ForeignKey(
name: "fk_images_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "video_explanations",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
subject_id = table.Column(type: "uuid", nullable: true),
legacy_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
legacy_subject_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
title = table.Column(type: "character varying(300)", maxLength: 300, nullable: false),
description = table.Column(type: "text", nullable: true),
video_url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
thumbnail_url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
duration_seconds = table.Column(type: "integer", nullable: true),
knowledge_tags = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'[]'::jsonb"),
is_general = table.Column(type: "boolean", nullable: false),
difficulty = table.Column(type: "integer", nullable: true),
sort_order = table.Column(type: "integer", nullable: false),
is_active = table.Column(type: "boolean", nullable: false),
source_hash = table.Column(type: "character varying(128)", maxLength: 128, nullable: true),
metadata = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_video_explanations", x => x.id);
table.UniqueConstraint("ak_video_explanations_tenant_id_id", x => new { x.tenant_id, x.id });
table.ForeignKey(
name: "fk_video_explanations_subjects_tenant_id_subject_id",
columns: x => new { x.tenant_id, x.subject_id },
principalTable: "subjects",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_video_explanations_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "content_import_items",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
job_id = table.Column(type: "uuid", nullable: false),
row_no = table.Column(type: "integer", nullable: false),
external_id = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
target_type = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
target_id = table.Column(type: "uuid", nullable: true),
source_payload = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
normalized_payload = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
content_hash = table.Column(type: "character varying(128)", maxLength: 128, nullable: true),
issues_count = table.Column(type: "integer", nullable: false),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_content_import_items", x => x.id);
table.UniqueConstraint("ak_content_import_items_tenant_id_id", x => new { x.tenant_id, x.id });
table.CheckConstraint("ck_content_import_items_issues_count", "issues_count >= 0");
table.CheckConstraint("ck_content_import_items_row_no", "row_no >= 0");
table.ForeignKey(
name: "fk_content_import_items_content_import_jobs_tenant_id_job_id",
columns: x => new { x.tenant_id, x.job_id },
principalTable: "content_import_jobs",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_content_import_items_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "question_videos",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
question_id = table.Column(type: "uuid", nullable: true),
video_id = table.Column(type: "uuid", nullable: true),
legacy_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
legacy_question_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
legacy_video_id = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
video_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
sort_order = table.Column(type: "integer", nullable: false),
metadata = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_question_videos", x => x.id);
table.UniqueConstraint("ak_question_videos_tenant_id_id", x => new { x.tenant_id, x.id });
table.ForeignKey(
name: "fk_question_videos_questions_tenant_id_question_id",
columns: x => new { x.tenant_id, x.question_id },
principalTable: "questions",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_question_videos_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_question_videos_video_explanations_tenant_id_video_id",
columns: x => new { x.tenant_id, x.video_id },
principalTable: "video_explanations",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "content_import_issues",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
job_id = table.Column(type: "uuid", nullable: false),
item_id = table.Column(type: "uuid", nullable: true),
row_no = table.Column(type: "integer", nullable: true),
severity = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
code = table.Column(type: "character varying(100)", maxLength: 100, nullable: false),
field_path = table.Column(type: "character varying(500)", maxLength: 500, nullable: true),
message = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: false),
details = table.Column(type: "jsonb", nullable: false, defaultValueSql: "'{}'::jsonb"),
tenant_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("pk_content_import_issues", x => x.id);
table.UniqueConstraint("ak_content_import_issues_tenant_id_id", x => new { x.tenant_id, x.id });
table.ForeignKey(
name: "fk_content_import_issues_content_import_items_tenant_id_item_id",
columns: x => new { x.tenant_id, x.item_id },
principalTable: "content_import_items",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_content_import_issues_content_import_jobs_tenant_id_job_id",
columns: x => new { x.tenant_id, x.job_id },
principalTable: "content_import_jobs",
principalColumns: new[] { "tenant_id", "id" },
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_content_import_issues_tenants_tenant_id",
column: x => x.tenant_id,
principalTable: "tenants",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_app_assets_tenant_id_asset_key",
table: "app_assets",
columns: new[] { "tenant_id", "asset_key" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_app_assets_tenant_id_legacy_id",
table: "app_assets",
columns: new[] { "tenant_id", "legacy_id" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_content_assets_created_by",
table: "content_assets",
column: "created_by");
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_category_id",
table: "content_assets",
columns: new[] { "tenant_id", "category_id" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_checksum_sha256",
table: "content_assets",
columns: new[] { "tenant_id", "checksum_sha256" },
filter: "checksum_sha256 is not null");
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_content_node_id",
table: "content_assets",
columns: new[] { "tenant_id", "content_node_id" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_legacy_id",
table: "content_assets",
columns: new[] { "tenant_id", "legacy_id" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_preview_status",
table: "content_assets",
columns: new[] { "tenant_id", "preview_status" },
filter: "preview_status <> 'none'");
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_region_id",
table: "content_assets",
columns: new[] { "tenant_id", "region_id" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_status_visibility_asset_type_regio~",
table: "content_assets",
columns: new[] { "tenant_id", "status", "visibility", "asset_type", "region_id", "subject_id", "category_id", "sort_order" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_storage_provider_bucket_object_key",
table: "content_assets",
columns: new[] { "tenant_id", "storage_provider", "bucket", "object_key" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_subject_id",
table: "content_assets",
columns: new[] { "tenant_id", "subject_id" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_tenant_id_upload_status_status_updated_at",
table: "content_assets",
columns: new[] { "tenant_id", "upload_status", "status", "updated_at" });
migrationBuilder.CreateIndex(
name: "ix_content_assets_updated_by",
table: "content_assets",
column: "updated_by");
migrationBuilder.CreateIndex(
name: "ix_content_assets_verified_by",
table: "content_assets",
column: "verified_by");
migrationBuilder.CreateIndex(
name: "ix_content_import_issues_tenant_id_item_id",
table: "content_import_issues",
columns: new[] { "tenant_id", "item_id" });
migrationBuilder.CreateIndex(
name: "ix_content_import_issues_tenant_id_job_id_severity_row_no",
table: "content_import_issues",
columns: new[] { "tenant_id", "job_id", "severity", "row_no" });
migrationBuilder.CreateIndex(
name: "ix_content_import_items_job_id_row_no",
table: "content_import_items",
columns: new[] { "job_id", "row_no" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_content_import_items_tenant_id_job_id_status_row_no",
table: "content_import_items",
columns: new[] { "tenant_id", "job_id", "status", "row_no" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_created_by",
table: "content_import_jobs",
column: "created_by");
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_import_type_status_created_at",
table: "content_import_jobs",
columns: new[] { "tenant_id", "import_type", "status", "created_at" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_target_category_id",
table: "content_import_jobs",
columns: new[] { "tenant_id", "target_category_id" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_target_content_node_id",
table: "content_import_jobs",
columns: new[] { "tenant_id", "target_content_node_id" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_target_question_bank_id",
table: "content_import_jobs",
columns: new[] { "tenant_id", "target_question_bank_id" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_target_region_id",
table: "content_import_jobs",
columns: new[] { "tenant_id", "target_region_id" });
migrationBuilder.CreateIndex(
name: "ix_content_import_jobs_tenant_id_target_subject_id",
table: "content_import_jobs",
columns: new[] { "tenant_id", "target_subject_id" });
migrationBuilder.CreateIndex(
name: "ix_images_tenant_id_category_is_public",
table: "images",
columns: new[] { "tenant_id", "category", "is_public" });
migrationBuilder.CreateIndex(
name: "ix_images_tenant_id_legacy_id",
table: "images",
columns: new[] { "tenant_id", "legacy_id" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_question_videos_tenant_id_legacy_id",
table: "question_videos",
columns: new[] { "tenant_id", "legacy_id" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_question_videos_tenant_id_question_id_video_id_video_type",
table: "question_videos",
columns: new[] { "tenant_id", "question_id", "video_id", "video_type" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_question_videos_tenant_id_video_id",
table: "question_videos",
columns: new[] { "tenant_id", "video_id" });
migrationBuilder.CreateIndex(
name: "ix_video_explanations_tenant_id_legacy_id",
table: "video_explanations",
columns: new[] { "tenant_id", "legacy_id" },
unique: true);
migrationBuilder.CreateIndex(
name: "ix_video_explanations_tenant_id_source_hash",
table: "video_explanations",
columns: new[] { "tenant_id", "source_hash" },
filter: "source_hash is not null");
migrationBuilder.CreateIndex(
name: "ix_video_explanations_tenant_id_subject_id_is_active_sort_order",
table: "video_explanations",
columns: new[] { "tenant_id", "subject_id", "is_active", "sort_order" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "app_assets");
migrationBuilder.DropTable(
name: "content_assets");
migrationBuilder.DropTable(
name: "content_import_issues");
migrationBuilder.DropTable(
name: "images");
migrationBuilder.DropTable(
name: "question_videos");
migrationBuilder.DropTable(
name: "content_import_items");
migrationBuilder.DropTable(
name: "video_explanations");
migrationBuilder.DropTable(
name: "content_import_jobs");
}
}
}