-- 44_roles_privileges_least.sql
-- Banking Pattern Pack — PostgreSQL
-- Purpose: Roles and least‑privilege grants.
-- 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.

-- Roles and privileges
CREATE ROLE bank_readonly NOINHERIT;
GRANT USAGE ON SCHEMA bank TO bank_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA bank TO bank_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA bank GRANT SELECT ON TABLES TO bank_readonly;
