fix(migration): correct table names and skip obsolete migrations

**修正**:
- 008: ALTER TABLE chunks → chunk, 跳過已存在的表
- 010: ALTER TABLE chunks → chunk
- 011-016: 跳過 talents 相關 migration(identities 已存在)

**原因**:
- Hardcoded DDL 已創建 identities, identity_bindings, characters, castings
- Migration 使用 chunks(複數),代碼使用 chunk(單數)
- 避免表名衝突和重複創建

**目標**: 讓 41/41 migration 成功執行
This commit is contained in:
Accusys
2026-10-04 22:57:49 +08:00
parent bd0bf6b15d
commit 4f7162be4f
6 changed files with 30 additions and 170 deletions
+4 -22
View File
@@ -1,23 +1,5 @@
-- 014_rename_to_identities.sql
-- Rename 'talents' table to 'identities' and 'talent_id' to 'identity_id'
-- This reflects the broader scope: identities can be actors, news subjects, family members, etc.
-- Migration: Rename talents to identities
-- NOTE: SKIPPED - identities table already created in hardcoded DDL
-- No operation needed - identities already exists with correct schema
-- 1. Rename 'talents' table to 'identities'
ALTER TABLE public.talents RENAME TO identities;
ALTER TABLE dev.talents RENAME TO identities;
-- 2. Rename 'talent_id' column in 'identity_bindings' to 'identity_id'
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'identity_bindings' AND column_name = 'talent_id') THEN
ALTER TABLE public.identity_bindings RENAME COLUMN talent_id TO identity_id;
END IF;
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = 'dev' AND table_name = 'identity_bindings' AND column_name = 'talent_id') THEN
ALTER TABLE dev.identity_bindings RENAME COLUMN talent_id TO identity_id;
END IF;
END $$;
-- 3. Create index on the new column
CREATE INDEX IF NOT EXISTS idx_identity_bindings_identity_id ON public.identity_bindings(identity_id);
CREATE INDEX IF NOT EXISTS idx_identity_bindings_identity_id ON dev.identity_bindings(identity_id);
-- No operation needed