xtablo-source/backend/migrations/0004_tasks.sql

26 lines
919 B
MySQL
Raw Permalink Normal View History

-- migrations/0004_tasks.sql
-- Phase 4: Tasks (Kanban)
-- +goose Up
-- ENUM declaration order must match visual left-to-right column order (Pitfall 6).
CREATE TYPE task_status AS ENUM ('todo', 'in_progress', 'in_review', 'done');
CREATE TABLE tasks (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
tablo_id uuid NOT NULL REFERENCES tablos(id) ON DELETE CASCADE,
title text NOT NULL,
description text,
status task_status NOT NULL DEFAULT 'todo',
position integer NOT NULL DEFAULT 100,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX tasks_tablo_id_status_idx ON tasks(tablo_id, status, position);
-- +goose Down
-- Table MUST be dropped before type (Pitfall 3 — type is still referenced by table column).
DROP TABLE IF EXISTS tasks;
DROP TYPE IF EXISTS task_status;