11 lines
687 B
SQL
11 lines
687 B
SQL
-- NPCs become a reusable, global template library rather than per-mystery copies.
|
|||
|
|
-- A NULL mystery_id marks a global template; mysteries reference templates by key
|
||
|
|
-- when authored, so editing an NPC in the admin panel survives re-imports.
|
||
|
|
ALTER TABLE osint.npcs ALTER COLUMN mystery_id DROP NOT NULL;
|
||
|
|
|
||
|
|
-- Enforce one global template per key (the existing UNIQUE(mystery_id, npc_key)
|
||
|
|
-- does not constrain rows where mystery_id IS NULL).
|
||
|
|
CREATE UNIQUE INDEX npcs_global_key_idx ON osint.npcs (npc_key) WHERE mystery_id IS NULL;
|
||
|
|
|
||
|
|
COMMENT ON TABLE osint.npcs IS 'Reusable NPC templates. mystery_id IS NULL for a global template; mysteries reference templates by npc_key when authored.';
|