-- Fix chain default status to 'pending' instead of 'active'
-- Chains should start as pending until explicitly started

-- Change default for new chains
ALTER TABLE chains ALTER COLUMN status SET DEFAULT 'pending';

-- Update any chains that have no contracts and are 'active' to 'pending'
-- (These were likely created but never properly started)
UPDATE chains
SET status = 'pending'
WHERE status = 'active'
  AND id NOT IN (SELECT DISTINCT chain_id FROM chain_contracts WHERE chain_id IS NOT NULL);
