Appearance
Database & Migrations
Migration fails, divergent schema, or connection error.
Symptoms
- Deploy fails with "migration error" or "schema mismatch"
- App starts but shows errors on specific entities
- Records missing or fields showing as null after deploy
- Connection error: "could not connect to database"
Diagnosis checklist
- Check the deployment log for the exact migration error message
- Confirm the environment is running (Dev/Staging/Prod)
- Check for pending migrations in Project Settings → Deployment History
- Check that environment variables for the database are set correctly
Common causes and solutions
Migration fails with a constraint error
Cause: adding a required field to an entity that already has records — the migration cannot set a NOT NULL constraint without a default value.
Solution:
- In the chat or Editor Mode, change the field to optional (not required)
- OR provide a default value for the field before making it required
- Deploy again after the fix
Schema mismatch (app errors after deploy)
Cause: the deployed code expects schema changes that didn't apply successfully.
- Check Deployment History for the failed migration step
- Rollback to the last stable version
- Fix the underlying issue (see constraint error above)
- Redeploy
Records missing after deploy
Cause: a migration with a destructive step ran (e.g., column rename or type change with data loss).
- Rollback immediately using Deployment History
- Review what changed in the failed deploy
- For column renames: use Editor Mode to change display labels only (not field names); renaming a field name creates a new column and drops the old one
Connection error
Cause: the database credentials or connection string are not set for this environment.
- Go to Runtime Settings → Environment Variables
- Verify that
DATABASE_URL(or the equivalent) is set correctly for this environment - If using a private database: ensure the network allows connections from the Madrix runtime
Migration best practices
- Always test migrations in Dev before promoting to Staging/Prod
- Avoid making fields required on entities with existing records without a default value
- Avoid renaming field names — change the display label instead
- Keep migrations small: one schema change per deploy cycle is easier to debug
- Monitor the deployment log during each deploy — don't walk away until it completes