--up

ALTER TABLE projects ALTER COLUMN project_state TYPE jsonb;
CREATE INDEX projects_live_user_id_id_idx ON projects (user_id, id) WHERE superseded_by IS NULL AND is_deleted = false;
CREATE INDEX projects_live_created_at_user_id_id_idx ON projects (created_at, user_id, id) WHERE superseded_by IS NULL AND is_deleted = false;
CREATE INDEX conductor_requests_user_id_id_idx ON conductor_requests (user_id, id);
CREATE INDEX conductor_requests_created_at_user_id_id_idx ON conductor_requests (created_at, user_id, id);
CREATE INDEX activity_action_user_id_id_idx ON activity (action, user_id, id);
CREATE INDEX activity_action_created_at_user_id_id_idx ON activity (action, created_at, user_id, id);
CREATE INDEX tracks_for_sharing_author_id_id_idx ON tracks_for_sharing (author_id, id);
CREATE INDEX tracks_for_sharing_created_at_author_id_id_idx ON tracks_for_sharing (created_at, author_id, id);
CREATE INDEX composer_requests_user_id_id_idx ON composer_requests (user_id, id);
CREATE INDEX composer_requests_created_at_user_id_id_idx ON composer_requests (created_at, user_id, id);

--down

ALTER TABLE projects ALTER COLUMN project_state TYPE json;
DROP INDEX projects_live_user_id_id_idx;
DROP INDEX projects_live_created_at_user_id_id_idx;
DROP INDEX conductor_requests_user_id_id_idx;
DROP INDEX conductor_requests_created_at_user_id_id_idx;
DROP INDEX activity_action_user_id_id_idx;
DROP INDEX activity_action_created_at_user_id_id_idx;
DROP INDEX tracks_for_sharing_author_id_id_idx;
DROP INDEX tracks_for_sharing_created_at_author_id_id_idx;
DROP INDEX composer_requests_user_id_id_idx;
DROP INDEX composer_requests_created_at_user_id_id_idx;