-- t-paliad-276 / m/paliad#108: per-draft output language for the
-- Submissions generator.
--
-- The submission editor lets the lawyer pick DE or EN per draft so the
-- generator selects the matching template variant + resolves language-
-- aware variables ({{procedural_event.name_de}} vs _en). Default is
-- 'de' to match the primary-language convention in CLAUDE.md and to
-- keep existing rows behaving exactly as before (every legacy draft
-- was implicitly DE; the resolved bag for those drafts is unchanged
-- under language='de').

ALTER TABLE paliad.submission_drafts
    ADD COLUMN IF NOT EXISTS language text NOT NULL DEFAULT 'de'
    CONSTRAINT submission_drafts_language_check CHECK (language IN ('de', 'en'));

COMMENT ON COLUMN paliad.submission_drafts.language IS
    't-paliad-276: output language for the generated .docx. ''de'' or ''en''. Drives template variant selection ({code}.{lang}.docx fallback chain) and language-aware variable resolution.';
