ALTER TABLE organizations ADD COLUMN IF NOT EXISTS automation_enabled boolean NOT NULL DEFAULT false; ALTER TABLE tasks ADD COLUMN IF NOT EXISTS confirmation_mode text NOT NULL DEFAULT 'manual'; ALTER TABLE tasks DROP CONSTRAINT IF EXISTS tasks_confirmation_mode_check; ALTER TABLE tasks ADD CONSTRAINT tasks_confirmation_mode_check CHECK (confirmation_mode IN ('manual', 'automatic')); CREATE INDEX IF NOT EXISTS tasks_confirmation_mode_idx ON tasks (organization_id, confirmation_mode, created_at DESC);