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:
@@ -1,26 +1,5 @@
|
||||
-- 015_rename_to_identities.sql
|
||||
-- Rename global 'talents' table to 'identities' and update foreign keys
|
||||
-- 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. Update indexes if needed
|
||||
DROP INDEX IF EXISTS public.idx_identity_bindings_talent_id;
|
||||
CREATE INDEX IF NOT EXISTS idx_identity_bindings_identity_id ON public.identity_bindings(identity_id);
|
||||
|
||||
DROP INDEX IF EXISTS dev.idx_identity_bindings_talent_id;
|
||||
CREATE INDEX IF NOT EXISTS idx_identity_bindings_identity_id ON dev.identity_bindings(identity_id);
|
||||
-- No operation needed
|
||||
|
||||
Reference in New Issue
Block a user