-- Add contract_type column to contracts table
-- Types: 'simple' (Plan -> Execute) or 'specification' (Research -> Specify -> Plan -> Execute -> Review)

ALTER TABLE contracts ADD COLUMN IF NOT EXISTS contract_type VARCHAR(32) NOT NULL DEFAULT 'simple';

-- Update existing contracts to 'simple' type (they can be manually changed if needed)
UPDATE contracts SET contract_type = 'simple' WHERE contract_type IS NULL;

CREATE INDEX IF NOT EXISTS idx_contracts_contract_type ON contracts(contract_type);

-- Add supervisor_task_id to contracts table if not exists
ALTER TABLE contracts ADD COLUMN IF NOT EXISTS supervisor_task_id UUID REFERENCES tasks(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_contracts_supervisor_task_id ON contracts(supervisor_task_id);
