ALTER TABLE environments RENAME TO iam_roles;

ALTER INDEX environments_pkey RENAME TO iam_roles_pkey;

ALTER SEQUENCE environments_id_seq RENAME TO iam_roles_id_seq;

ALTER TABLE iam_roles
    ADD CONSTRAINT unique_iam_role UNIQUE (iam_role),
    ADD CONSTRAINT unique_service_id_label UNIQUE (service_id, label),
    DROP CONSTRAINT environments_service_id_fkey,
    ADD CONSTRAINT iam_roles_service_id_fkey FOREIGN KEY (service_id) REFERENCES services (id)
        ON UPDATE CASCADE
        ON DELETE CASCADE,
    ALTER COLUMN cloudformation_status TYPE TEXT;

ALTER TABLE iam_roles RENAME COLUMN iam_role TO arn;
