start.sh:
- Added fallback defaults for DB_USER, DB_HOST, DB_DATABASE, DB_PASSWORD
- Ensures psql always uses 'postgres' user even if env vars missing
- Added debug logging to show which credentials are being used
complete_schema.sql:
- Permissions Protocol now checks if directus_policies table exists first
- Silently skips on first boot (before Directus creates its tables)
- Prevents SQL errors during fresh install
SCHEMA UPDATE:
- Added Permissions Grant Protocol to complete_schema.sql
- Auto-grants Admin role CRUD access to all 13 new collections
- Runs automatically during fresh install
- Uses ON CONFLICT DO NOTHING for safe re-runs
CTO DOCS UPDATE:
- Added Section 9A: Stability Patch & Permissions Protocol
- Documents the Foundation Gap resolution
- Includes manual patch instructions for existing DBs
- Verification checklist after patching
ANALYTICS ENGINE (4 tables):
- site_analytics: GA/Ads/Pixel tracking config
- events: Custom event tracking
- pageviews: Page view analytics
- conversions: Conversion tracking with lead linking
GEO-INTELLIGENCE (3 tables):
- locations_states: 50 US states with codes
- locations_counties: 3,143 counties
- locations_cities: Cities with lat/long, zip codes
LEAD CAPTURE (2 tables):
- forms: Dynamic form builder
- form_submissions: Form data storage
SITE BUILDER (3 tables):
- navigation: Self-referential menu system
- globals: Site-wide settings (singleton per site)
- hub_pages: Hierarchical content hubs
SYSTEM (1 table):
- work_log: Activity logging
Also added Directus UI configs for all new FK fields.
Schema now has 28 tables matching TypeScript types.