CRE-2025-0135
Supabase Self-Hosted: Database Migration Failures Due to SQL Syntax ErrorsMediumImpact: 7/10Mitigation: 6/10
Description
Detects when Supabase database migrations fail due to SQL syntax errors, invalid schema changes,\nor constraint violations. Migration failures can leave the database in an inconsistent state and\nprevent the application from starting or functioning properly.\n
Mitigation
IMMEDIATE:\n - Check database logs for specific SQL error details\n - Identify failing migration file and line number\n - Stop database container to prevent further damage\nRECOVERY:\n - Fix SQL syntax errors in migration files\n - Remove invalid migration files from migrations directory\n - Restore database from backup if migrations corrupted data\n - Manually run corrected migrations step by step\nVALIDATION:\n - Test migrations on development database first\n - Use SQL linting tools to validate syntax\n - Implement migration rollback procedures\n - Add migration validation to CI/CD pipeline\nPREVENTION:\n - Use database migration tools with validation\n - Create database backups before running migrations\n - Implement proper foreign key constraint order\n - Use transaction-wrapped migrations for atomicity\n