Skip to content
Back to skills

Db Migrations

ASecurity

How to create and use our alembic database migration tool. Use when making changes to models.py.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
databasessqlawsdatabase

Security analysis

A100/100

Scanned February 10, 2026

npx -y skills add majiayu000/claude-skill-registry --skill db-migrations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Db Migrations?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Db Migrations
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-db-migrations/badge)](https://www.skillsdirectory.com/skills/majiayu000-db-migrations)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: database-migrations
description: How to create and use our alembic database migration tool. Use when making changes to models.py.
---

## Instructions

Do not write out alembic migrations yourself. Use the alembic tool to generate and apply migrations.
You do not need to give alembic the path to alembic.ini.
Do not manually drop any tables or columns in the DB. Always use alembic migrations to make schema changes.

Alembic depends on having a valid DATABASE_URL set. The username should be inspect_admin. The password will be automatically generated via RDS IAM.

The URL depends on the environment you are working in. E.g. it should follow a pattern like DATABASE_URL='postgresql://inspect_admin@{environment}-inspect-ai-warehouse.cluster-{cluster-id}.{region}.rds.amazonaws.com/inspect'
`tofu output -var-file="${ENVIRONMENT}.tfvars" -raw warehouse_database_url_admin` will return the correct URL for the given environment.

Make sure to have AWS_PROFILE=staging set for RDS IAM auth and tofu commands.

To create a new migration, run:

`alembic revision --autogenerate -m "description of changes"`

Run `ruff check --fix && ruff format` to silence any formatting issues in the generated migration file.

You may need to ensure the DB is up to date before generating a new migration. Run:
`alembic upgrade head`

If we want to regenerate a migration file (in a branch we're working on after making schema changes since the last migration), we can delete the previous migration file and run the revision command again.

1. Run `alembic downgrade -1` to revert the last migration.
2. Delete the migration file from the versions/ directory.
3. Run `alembic upgrade head` to ensure the DB is up to date.
4. Run the revision command again to generate a new migration file.

## Verification

Run the tests in `tests/core/db/test_alembic_migrations.py`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.