Commit Graph

12 Commits

Author SHA1 Message Date
Matt f81da356cc Fix init.sql table grant ordering
Build and Push Docker Image / build (push) Successful in 2m49s Details
Move GRANT statements for document_folders and user_notification_preferences
to after their respective CREATE TABLE statements. The grants were failing
because they referenced tables that hadn't been created yet.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:52:07 +01:00
Matt 274b13fe1e Add notifications system, fix button href, admin settings and welcome email
Build and Push Docker Image / build (push) Successful in 1m55s Details
- Fix admin settings 502 error by adding INSERT/UPDATE/DELETE grants
- Fix Button component to render <a> when href prop is provided
- Add welcome email for admin created during initial setup
- Add in-app notifications system with NotificationCenter component
- Add notifications table with RLS policies and welcome trigger
- Add API endpoints for fetching and marking notifications as read

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:04:27 +01:00
Matt 2451582dc6 Complete database grants and update README
Build and Push Docker Image / build (push) Successful in 1m52s Details
init.sql changes:
- Add INSERT grant for members table (for /join signup)
- Add INSERT grant for dues_payments (for board recording payments)
- Add full CRUD grants for events, documents, document_folders
- Add UPDATE grant for email_templates (admin management)
- Add anon role grants for public event viewing and RSVP creation

README changes:
- Add "Important Notes" section explaining dynamic env vars
- Add first-time setup and database initialization docs
- Add troubleshooting for 403 errors with grant fix commands
- Add troubleshooting for "account not configured" errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:44:25 +01:00
Matt dc0198dcad Add comprehensive table grants for authenticated role
Build and Push Docker Image / build (push) Successful in 1m54s Details
RLS policies define WHAT rows can be accessed, but GRANT statements
control WHETHER a table can be accessed at all. This was causing 403
errors when authenticated users tried to access tables.

Added grants for:
- Core tables: members, membership_statuses, membership_types
- Dues: dues_payments (SELECT)
- Events: events, event_types, event_rsvps (full CRUD), event_rsvps_public
- Documents: documents, document_categories, document_folders
- Settings: app_settings (SELECT for public settings)
- Email: email_logs (SELECT for own logs)
- Preferences: user_notification_preferences (SELECT, INSERT, UPDATE)
- Views: members_with_dues, events_with_counts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 15:40:47 +01:00
Matt c74525e113 Make phone, date_of_birth, address nullable in members table
Build and Push Docker Image / build (push) Successful in 1m53s Details
These fields can be filled in later by the user. The admin setup page
only collects essential fields (name, email, password).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 14:06:10 +01:00
Matt cfbf7639c2 Add password setup script for Supabase roles
Build and Push Docker Image / build (push) Successful in 1m51s Details
The Supabase postgres image's internal migrate.sh requires supabase_admin
to have a password matching POSTGRES_PASSWORD. Added zz-set-passwords.sh
to run after init.sql and set passwords dynamically using the environment
variable.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:57:35 +01:00
Matt 0e93961bb9 Remove hardcoded supabase_admin password from init.sql
Build and Push Docker Image / build (push) Successful in 1m48s Details
The Supabase postgres image sets these passwords based on POSTGRES_PASSWORD.
Hardcoding 'postgres' caused the image's migrate.sh to fail.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:20:46 +01:00
Matt c8efc3859c Wrap storage operations in conditionals for fresh db init
Build and Push Docker Image / build (push) Successful in 1m46s Details
- storage.objects and storage.buckets are created by storage-api service
- Wrapped all storage bucket inserts and policy operations in DO blocks
- Check if table exists before running storage operations
- Prevents errors during initial database setup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:14:32 +01:00
Matt ce3239598d Add auth helper functions (uid, role, jwt) to init.sql
Build and Push Docker Image / build (push) Successful in 1m45s Details
These functions are normally created by GoTrue but our init.sql
runs first. Needed for RLS policies that use auth.uid().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:12:33 +01:00
Matt 679f278075 Grant service_role full access to all public tables
Build and Push Docker Image / build (push) Successful in 1m46s Details
Added GRANT ALL for service_role on:
- membership_statuses, membership_types, members tables
- All tables and sequences in public schema
- Default privileges for future tables

Fixes 'permission denied' errors during admin setup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:10:21 +01:00
Matt 4039ec8187 Remove FK references to auth.users from init.sql
Build and Push Docker Image / build (push) Successful in 1m55s Details
The auth.users table is created by GoTrue, not the database init.
FK constraints to auth.users fail because init.sql runs before auth starts.
Removed FK from members and audit_logs tables.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:58:31 +01:00
Matt 3187f5babb Add standalone production deployment package
Build and Push Docker Image / build (push) Successful in 1m46s Details
- docker-compose.yml: Standalone compose with Traefik, Supabase, portal
- init.sql: Combined database schema + all 16 migrations
- kong.yml.template: Kong config with API key placeholders
- setup.sh: Auto-generates secrets (JWT, passwords, API keys)
- .env.example: Comprehensive environment template
- README.md: Complete deployment guide

No source code cloning required - just copy files and run setup.sh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:15:56 +01:00