Database Migration

Generate, review, and apply Alembic migrations for database schema changes.

Updated Jan 10, 2026
One-click install
npx skills add https://github.com/Bedriftsgrafen/bedriftsgrafen.no --skill database-migration-bedriftsgrafen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Database Migration
Source: https://github.com/Bedriftsgrafen/bedriftsgrafen.no/tree/main/.agent/skills/database_migration
Command: npx skills add https://github.com/Bedriftsgrafen/bedriftsgrafen.no --skill database-migration-bedriftsgrafen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Safe and structured management of database schema changes using Alembic, reducing drift and errors.

Core Features & Use Cases

  • Automatic generation of migrations from model changes with alembic revision --autogenerate.
  • Safe review, testing, and application of migrations to local and shared databases.
  • Use case: when you modify backend/models/*.py and need controlled schema changes across environments.

Quick Start

Modify the backend models, generate a migration, review the generated file, and apply the migration to the database.

Frequently Asked Questions about Database Migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate Alembic migrations automatically from Python model changes?

To generate Alembic migrations automatically from Python model changes, modify your backend/models/*.py files and run alembic revision --autogenerate. This creates a new migration file capturing the schema differences for you to review before applying.

What is the safest way to apply database schema changes across different environments?

The safest way to apply database schema changes across environments is using Alembic migrations. This approach ensures versioned, tested changes with minimal risk by generating, reviewing, and applying migration files to maintain consistency across local and shared databases.

How do I prevent database schema drift when modifying backend models in Python?

To prevent database schema drift when modifying backend models in Python, use Alembic to manage versioned schema changes. By generating and applying tested migration files, you ensure structured updates and reduce errors across all database environments.

Do I need to review autogenerated Alembic migration files before applying them?

Yes, you need to review autogenerated Alembic migration files before applying them. Reviewing the generated schema change files performs necessary safety checks and ensures the versioned changes are correct, minimizing risk before updating local or shared databases.

Can I use Alembic for database versioning without manually writing schema change scripts?

Yes, you can use Alembic for database versioning without manually writing schema change scripts by using alembic revision --autogenerate. It detects model modifications and automatically creates the migration files for you to review and apply.