ALTER TABLE subscription_plans ADD COLUMN IF NOT EXISTS is_free BOOLEAN NOT NULL DEFAULT FALSE; -- Legacy zero-price rows become explicitly free before the price constraint is enforced. UPDATE subscription_plans SET is_free = TRUE WHERE price = 0 AND is_free = FALSE; ALTER TABLE subscription_plans ADD CONSTRAINT chk_subscription_plans_free_price CHECK ( (is_free = TRUE AND price = 0) OR (is_free = FALSE AND price > 0) );