Source:
ocean/docs/adr/030-production-database-migration-issue.md| ✏️ Edit on GitHub
ADR-030: Production Database Migration Issue - Missing Tables
Status
Accepted
Date
2025-08-28
Context
During user signup testing, we discovered a critical issue where the provisioning_events table (and potentially other tables) don't exist in the production database. The error message revealed:
ERROR: relation "provisioning_events" does not exist (SQLSTATE 42P01)
This indicates that the initial database migration (20250812233110_initial_schema.sql) was never applied to production, even though the application has been deployed multiple times.
Investigation
- Local Environment: All tables exist and function correctly
- Production Environment: Core tables are missing, causing signup failures
- Error Pattern:
- User attempts to sign up
handle_new_usertrigger fires- Trigger attempts to log to
provisioning_eventstable - Transaction fails with "table does not exist" error
Decision
We need to ensure all migrations are properly applied to production:
-
Immediate Fix:
- Monitor the current deployment triggered by commit
306c1d1 - Verify migrations are applied via GitHub Actions logs
- If migrations fail, manually apply them through Supabase dashboard
- Monitor the current deployment triggered by commit
-
Long-term Solution:
- Add migration status checks to deployment workflow
- Implement pre-deployment database health checks
- Add monitoring alerts for migration failures
Consequences
Positive
- Once migrations are applied, signup functionality will work correctly
- We've identified a gap in our deployment process
- Future deployments will be more reliable with proper checks
Negative
- All signup attempts have been failing in production
- Users have been unable to create accounts
- Trust in the platform may have been affected
Neutral
- This is a one-time issue that shouldn't recur once properly fixed
- The fix doesn't require code changes, only proper migration execution
Implementation Notes
Verifying Migration Status
-- Check if critical tables exist
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name IN (
'provisioning_events',
'organizations',
'organization_members',
'profiles',
'organization_databases'
);
-- Check migration history
SELECT version, name, executed_at
FROM supabase_migrations.schema_migrations
ORDER BY executed_at DESC;
Manual Migration (if needed)
If automatic migration fails, apply through Supabase Dashboard:
- Go to SQL Editor
- Run each migration file in order starting from
20250812233110_initial_schema.sql - Verify tables are created
- Test signup flow
Monitoring
Add these checks to prevent future issues:
- GitHub Actions should verify migration success
- Add Sentry alerts for "table does not exist" errors
- Implement database health endpoint that checks critical tables
Related Issues
- User signup failures
- "Database error saving new user" messages
- GraphQL error handling fix (commit
306c1d1)
References
- Supabase Migration Documentation
- GitHub Actions Workflow
- Initial schema migration:
supabase/migrations/20250812233110_initial_schema.sql