DROP TYPE IF EXISTS "IssueStatus" CASCADE;
CREATE TYPE "IssueStatus" AS ENUM (
    'backlog',
    'selected',
    'in_progress',
    'done'
);
ALTER TABLE issues ADD COLUMN status "IssueStatus";
UPDATE issues
SET status = issue_statuses.name :: "IssueStatus"
FROM issue_statuses
WHERE issue_statuses.id = issues.issue_status_id;

ALTER TABLE issues DROP COLUMN issue_status_id;
ALTER TABLE issues ALTER COLUMN status SET NOT NULL;
DROP TABLE issue_statuses;
