Migrations

This commit is contained in:
2026-03-01 18:51:53 +08:00
parent 2100516238
commit 830c99a3ff
7 changed files with 160 additions and 0 deletions
@@ -0,0 +1,24 @@
-- Add 'cancelled' to task_status enum (if it exists) and add cancellation_reason column
DO $$
BEGIN
-- Add enum value if task_status enum exists
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'task_status') THEN
IF NOT EXISTS (
SELECT 1
FROM pg_enum
JOIN pg_type ON pg_enum.enumtypid = pg_type.oid
WHERE pg_type.typname = 'task_status' AND pg_enum.enumlabel = 'cancelled'
) THEN
ALTER TYPE task_status ADD VALUE 'cancelled';
END IF;
END IF;
-- Add cancellation_reason column if it doesn't exist
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name='tasks' AND column_name='cancellation_reason'
) THEN
ALTER TABLE public.tasks ADD COLUMN cancellation_reason text;
END IF;
END
$$;