-- Reverse 024_rename_department_columns: put back the German names.
DO $$ BEGIN ALTER POLICY department_members_write  ON paliad.department_members RENAME TO dezernat_mitglieder_write;  EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER POLICY department_members_select ON paliad.department_members RENAME TO dezernat_mitglieder_select; EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER POLICY departments_write         ON paliad.departments        RENAME TO dezernate_write;            EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER POLICY departments_select        ON paliad.departments        RENAME TO dezernate_select;           EXCEPTION WHEN undefined_object THEN NULL; END $$;

DO $$ BEGIN ALTER INDEX paliad.department_members_user_idx   RENAME TO dezernat_mitglieder_user_idx;   EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER INDEX paliad.departments_lead_idx          RENAME TO dezernate_lead_idx;             EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER INDEX paliad.departments_office_idx        RENAME TO dezernate_office_idx;           EXCEPTION WHEN undefined_object THEN NULL; END $$;

DO $$ BEGIN ALTER TABLE paliad.department_members RENAME CONSTRAINT department_members_user_id_fkey         TO dezernat_mitglieder_user_id_fkey;     EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER TABLE paliad.department_members RENAME CONSTRAINT department_members_department_id_fkey   TO dezernat_mitglieder_dezernat_id_fkey; EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER TABLE paliad.department_members RENAME CONSTRAINT department_members_pkey                 TO dezernat_mitglieder_pkey;             EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER TABLE paliad.departments        RENAME CONSTRAINT departments_office_check                TO dezernate_office_check;               EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER TABLE paliad.departments        RENAME CONSTRAINT departments_lead_user_id_fkey           TO dezernate_lead_user_id_fkey;          EXCEPTION WHEN undefined_object THEN NULL; END $$;
DO $$ BEGIN ALTER TABLE paliad.departments        RENAME CONSTRAINT departments_pkey                        TO dezernate_pkey;                       EXCEPTION WHEN undefined_object THEN NULL; END $$;

DO $$ BEGIN ALTER TABLE paliad.department_members RENAME COLUMN department_id TO dezernat_id; EXCEPTION WHEN undefined_column OR undefined_table THEN NULL; END $$;
