7 Commits

Author SHA1 Message Date
cawcenter
6465c3d1f8 🔧 FIX: Prevent 'role root does not exist' PostgreSQL error
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
2025-12-14 15:05:35 -05:00
cawcenter
0a20519bf4 🔐 PERMISSIONS GRANT PROTOCOL v1.0: Auto-unlock new collections
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
2025-12-14 14:38:42 -05:00
cawcenter
bbf2127f5d 🚀 STABILITY PATCH v1.0: Added 13 missing tables to Golden Schema
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.
2025-12-14 14:32:23 -05:00
cawcenter
a74a4e946d Refactor Directus types: rename to schemas.ts, fix imports, and resolve type errors 2025-12-14 12:48:08 -05:00
cawcenter
99f406e998 schema: implement Golden Schema with Harris Matrix ordering + Directus UI config
- Batch 1 (Foundation): sites, campaign_masters, 5 independent tables
- Batch 2 (Walls): 7 first-level children
- Batch 3 (Roof): link_targets
- Directus UI: Auto-configure dropdowns for all foreign keys
- Fix template bug: campaign_name → name
- Proper dependency ordering prevents constraint failures
2025-12-14 12:21:17 -05:00
cawcenter
29337e8f42 fix: add missing parent tables and correct field names in schema
CRITICAL FIXES:
- Added 'sites' table (SUPER PARENT) - referenced by 10+ tables
- Added 'campaign_masters' table - referenced by 3 tables
- Fixed field names: campaign → campaign_id, site → site_id
- Organized schema into dependency batches (Batch 1→2→3)

This fixes the root cause of foreign key constraint failures.
2025-12-14 12:15:06 -05:00
cawcenter
7b95b7251d feat: complete database schema with all 39 tables and foreign key relationships 2025-12-14 10:16:01 -05:00