-- t-paliad-122: rollback courts entity + per-country holidays.
DROP TABLE IF EXISTS paliad.courts;

ALTER TABLE paliad.holidays DROP CONSTRAINT IF EXISTS holidays_country_fk;
ALTER TABLE paliad.holidays DROP CONSTRAINT IF EXISTS holidays_country_or_regime_chk;
ALTER TABLE paliad.holidays DROP CONSTRAINT IF EXISTS holidays_regime_chk;
ALTER TABLE paliad.holidays DROP CONSTRAINT IF EXISTS holidays_date_name_country_regime_key;
DROP INDEX IF EXISTS paliad.holidays_regime_idx;

-- Restore the original UNIQUE.
ALTER TABLE paliad.holidays
    ADD CONSTRAINT holidays_date_name_country_key UNIQUE (date, name, country);

-- Restore the country='UPC' rows so post-rollback state matches pre-053.
UPDATE paliad.holidays
   SET country = 'UPC',
       regime  = NULL
 WHERE regime = 'UPC';

ALTER TABLE paliad.holidays ALTER COLUMN country SET DEFAULT 'DE';
ALTER TABLE paliad.holidays ALTER COLUMN country SET NOT NULL;
ALTER TABLE paliad.holidays DROP COLUMN regime;

DROP TABLE IF EXISTS paliad.countries;
