-- t-paliad-116 B: paliad.event_deadlines.notes_en column + DE/EN swap
-- for the three rows that ship English text in the (DE-named) notes
-- column.
--
-- The DTO has long emitted `notes` directly into the EN render, so the
-- pattern matches t-112 mig 032 for deadline_rules: add a parallel
-- notes_en column, render path prefers _en when locale=EN and falls
-- back to notes (DE) when NULL.
--
-- Three rows currently leak English into the DE locale (ids 50, 52, 70):
--   50, 52: "Or 20 Working days, whichever is longer"
--   70:     "The 262.2 application can also be filed for opponent
--           submissions to protect confidential information disclosed
--           by the opponent."
-- For those rows we (1) copy the existing English string verbatim into
-- notes_en, and (2) overwrite notes with the proper DE translation so
-- the DE locale stops leaking.

ALTER TABLE paliad.event_deadlines
    ADD COLUMN IF NOT EXISTS notes_en text;

COMMENT ON COLUMN paliad.event_deadlines.notes_en IS
    'English translation of notes. Render path prefers this column when '
    'the active locale is EN; falls back to notes (DE) when NULL.';

-- Step 1: preserve current English text in notes_en for the three rows
-- that have it.
UPDATE paliad.event_deadlines SET notes_en = CASE id
    WHEN 50 THEN 'Or 20 Working days, whichever is longer'
    WHEN 52 THEN 'Or 20 Working days, whichever is longer'
    WHEN 70 THEN 'The 262.2 application can also be filed for opponent submissions to protect confidential information disclosed by the opponent.'
    ELSE notes_en
END
WHERE id IN (50, 52, 70);

-- Step 2: replace the leaking English text in the DE-named notes column
-- with proper DE translations.
UPDATE paliad.event_deadlines SET notes = CASE id
    WHEN 50 THEN 'Oder 20 Werktage, je nachdem, was länger ist'
    WHEN 52 THEN 'Oder 20 Werktage, je nachdem, was länger ist'
    WHEN 70 THEN 'Der Antrag nach Regel 262.2 kann auch für Schriftsätze der einsprechenden Partei gestellt werden, um vertrauliche Informationen zu schützen, die von der einsprechenden Partei offengelegt wurden.'
    ELSE notes
END
WHERE id IN (50, 52, 70);
