-- 27_array_account_flags.sql
-- Banking Pattern Pack — PostgreSQL
-- Purpose: Account flags as TEXT[] with queries.
-- 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.

-- Account flags as TEXT[]
ALTER TABLE bank.accounts ADD COLUMN IF NOT EXISTS flags TEXT[] DEFAULT ARRAY[]::text[];
UPDATE bank.accounts SET flags = ARRAY['vip','sms_opt_in'] WHERE account_id = 1;
SELECT * FROM bank.accounts WHERE flags @> ARRAY['vip'];
