-- 64_generated_columns_demo.sql
-- Banking Pattern Pack — PostgreSQL
-- Purpose: Generated columns for denormalized fields.
-- 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;

-- Generated columns: store last4 of IBAN
ALTER TABLE bank.accounts ADD COLUMN IF NOT EXISTS iban_last4 TEXT GENERATED ALWAYS AS (right(iban, 4)) STORED;
