-- Migration 022: Customer address constraint
-- Enforce single active address per customer

-- Only one active address per customer
-- When address changes, old address is deactivated, new one becomes active
CREATE UNIQUE INDEX idx_customer_address_one_active
    ON customer_addresses (customer_id) WHERE is_active = true;
