bitque/migrations/2020-05-06-130610_add_custom_columns/down.sql

17 lines
486 B
MySQL
Raw Normal View History

2023-04-01 22:31:57 +02:00
DROP TYPE IF EXISTS "IssueStatusMapping" CASCADE;
CREATE TYPE "IssueStatusMapping" AS ENUM (
2020-05-06 22:24:58 +02:00
'backlog',
'selected',
'in_progress',
'done'
);
2023-04-01 22:31:57 +02:00
ALTER TABLE issues ADD COLUMN status "IssueStatusMapping";
2020-05-06 22:24:58 +02:00
UPDATE issues
2023-04-01 22:31:57 +02:00
SET status = issue_statuses.name :: "IssueStatusMapping"
2020-05-06 22:24:58 +02:00
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;