ALTER TABLE gdpr.requests RENAME TO takeout;

ALTER INDEX IF EXISTS requests_uid_idx RENAME TO takeout_uid_idx;


ALTER TABLE gdpr.takeout DROP CONSTRAINT requests_pkey;
ALTER TABLE gdpr.takeout ALTER COLUMN request_id SET NOT NULL;

ALTER TABLE gdpr.takeout ADD COLUMN takeout_id bigserial PRIMARY KEY;



CREATE UNIQUE INDEX IF NOT EXISTS takeout_check_unique_uncompleted
    ON gdpr.takeout USING btree (uid) WHERE completed_at IS NULL;


ALTER TABLE gdpr.takeout DROP COLUMN status;

DROP TYPE gdpr.request_status;
