-- zrusenie enum v ACL a jeho konverzia na varchar

BEGIN;

ALTER TABLE acl ADD COLUMN dataset_name_new VARCHAR;
UPDATE acl SET dataset_name_new=dataset_name::VARCHAR;
ALTER TABLE acl ALTER COLUMN dataset_name_new SET NOT NULL;

DROP INDEX acl_dataset_name_person_role_dataset_id;
ALTER TABLE acl DROP COLUMN dataset_name;
DROP TYPE enum_acl_dataset_name;
ALTER TABLE acl RENAME COLUMN dataset_name_new TO dataset_name;

CREATE INDEX acl_dataset_name_person_role_dataset_id
	ON acl (dataset_name, person, person_role, dataset_id);

COMMIT;
