-- 62_citext_case_insensitive.sql
-- Banking Pattern Pack — PostgreSQL
-- Purpose: citext for case‑insensitive email unique.
-- Context: Retail bank example with customers, accounts, transactions, cards, loans.
-- Date: 2025-08-18
-- Notes:
--   * Safe to read; run on a development DB.
--   * Requires: CREATE privileges; some files may need superuser for extensions.
--   * Search path set to 'bank' schema for clarity.
SET search_path = bank, public;

-- Case‑insensitive emails
CREATE EXTENSION IF NOT EXISTS citext;
ALTER TABLE bank.customers ALTER COLUMN email TYPE citext;
ALTER TABLE bank.customers ADD CONSTRAINT customers_email_ci_unique UNIQUE (email);
