skills/database-migration/SKILL.md
Run database migrations safely during deployment — framework-specific commands, pre-deploy vs post-deploy timing, health gates, and rollback strategies. Use when the app has a database migration system and needs migrations run during deployment.
npx skillsauth add nixopus/agent database-migrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Check for migration tooling in the project:
| Signal | Migration tool | Ecosystem |
|---|---|---|
| prisma/schema.prisma or @prisma/client in deps | Prisma | Node.js |
| typeorm in deps + ormconfig or data-source.ts | TypeORM | Node.js |
| knex in deps + knexfile | Knex | Node.js |
| drizzle-orm in deps + drizzle.config.ts | Drizzle | Node.js |
| sequelize in deps + config/config.json | Sequelize | Node.js |
| manage.py + Django in deps | Django | Python |
| alembic/ directory or alembic in deps | Alembic | Python |
| flask-migrate in deps | Flask-Migrate | Python |
| goose or migrate in go.mod | Goose / golang-migrate | Go |
| ActiveRecord + db/migrate/ | Rails Migrations | Ruby |
| ecto in mix.exs | Ecto | Elixir |
| flyway or liquibase in pom.xml / build.gradle | Flyway / Liquibase | Java |
| Entity Framework in .csproj | EF Core | .NET |
| Tool | Migrate command | Status/check command |
|---|---|---|
| Prisma | npx prisma migrate deploy | npx prisma migrate status |
| TypeORM | npx typeorm migration:run | npx typeorm migration:show |
| Knex | npx knex migrate:latest | npx knex migrate:status |
| Drizzle | npx drizzle-kit migrate | npx drizzle-kit check |
| Sequelize | npx sequelize-cli db:migrate | npx sequelize-cli db:migrate:status |
| Django | python manage.py migrate | python manage.py showmigrations |
| Alembic | alembic upgrade head | alembic current |
| Flask-Migrate | flask db upgrade | flask db current |
| Goose | goose up | goose status |
| golang-migrate | migrate -path ./migrations -database $DATABASE_URL up | migrate ... version |
| Rails | bundle exec rake db:migrate | bundle exec rake db:migrate:status |
| Ecto | mix ecto.migrate | mix ecto.migrations |
| Flyway | flyway migrate | flyway info |
| Liquibase | liquibase update | liquibase status |
| EF Core | dotnet ef database update | dotnet ef migrations list |
Use when: new code REQUIRES the schema change to function.
migrate service with depends_on before the app serviceUse when: migration is additive (new columns/tables) and old code wouldn't break.
| Framework | Pattern | Implementation |
|---|---|---|
| Prisma | Entrypoint script | npx prisma migrate deploy && node dist/index.js |
| Django | Entrypoint script | python manage.py migrate && gunicorn ... |
| Rails | Entrypoint script | bundle exec rake db:migrate && bundle exec puma ... |
| Alembic | Pre-deploy step | Run alembic upgrade head before deploying |
| Ecto | Release command | mix ecto.migrate as release pre-start hook |
| EF Core | Pre-deploy step | dotnet ef database update before deploying |
For compose deployments, add a migration service that runs before the app:
services:
migrate:
build: .
command: npx prisma migrate deploy
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/app
depends_on:
db:
condition: service_healthy
app:
build: .
depends_on:
migrate:
condition: service_completed_successfully
db:
condition: service_healthy
When migrations run at container startup:
#!/bin/sh
set -e
echo "Running migrations..."
npx prisma migrate deploy
echo "Starting application..."
exec node dist/index.js
Key: use exec for the final command so the app process becomes PID 1 and receives signals correctly.
migrate deploy / migrate:latest (not push or sync) — deploy applies migration files in order; push/sync can be destructivemigrate deploy vs db push: deploy applies migration files; push syncs schema directly (destructive, dev-only)migrate with --run-syncdb can create tables without migration files — avoid in productionsynchronize: true in production drops and recreates tables — ensure it's disabledautogenerate may miss some changes (custom types, triggers) — always review generated migrationsdb:schema:load vs db:migrate: schema:load replaces all migrations with a single schema load — only use for new databasesUpdate-Database in Package Manager Console is interactive — use dotnet ef database update for Dockerpre-deploy-checklist — Detects migration tools and checks if migration command is in the deploy flowrollback-strategy — Guidance on rolling back when migrations make rollback riskycompose-setup — Migration service pattern for compose deploymentstools
Compressed catalog of all Nixopus API operations for the nixopus_api() tool
development
Deploy static file sites — Caddy/nginx serving, Staticfile config, and Dockerfile patterns. Use when deploying a static HTML site with no server-side runtime, or when index.html or a Staticfile is detected at the project root.
devops
Deploy shell script applications — interpreter detection, setup scripts, and Dockerfile patterns. Use when deploying a shell script project, or when start.sh is detected.
development
Self-healing loop for failed deployments — diagnose, fix, redeploy up to 3 attempts, then escalate or rollback. Load when a deployment fails or build errors occur.