Files
coder/coderd/database/migrations/000340_workspace_app_status_idle.down.sql
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
749 B
SQL
Raw Normal View History

2025-06-20 14:34:31 -08:00
-- It is not possible to delete a value from an enum, so we have to recreate it.
CREATE TYPE old_workspace_app_status_state AS ENUM ('working', 'complete', 'failure');
-- Convert the new "idle" state into "complete". This means we lose some
-- information when downgrading, but this is necessary to swap to the old enum.
UPDATE workspace_app_statuses SET state = 'complete' WHERE state = 'idle';
-- Swap to the old enum.
ALTER TABLE workspace_app_statuses
ALTER COLUMN state TYPE old_workspace_app_status_state
USING (state::text::old_workspace_app_status_state);
-- Drop the new enum and rename the old one to the final name.
DROP TYPE workspace_app_status_state;
ALTER TYPE old_workspace_app_status_state RENAME TO workspace_app_status_state;