Generate database migration files using the Akron CLI for schema changes across SQLite, MySQL, PostgreSQL, and MongoDB.
The makemigrations
command generates migration files that describe changes to your database schema. These files can be version controlled and applied across different environments to keep database schemas in sync.
akron makemigrations --db <database_url> [options]
Type: str (required)
Database connection URL to generate migrations for.
Type: str (optional)
Custom name for the migration file. Auto-generated if not provided.
Type: str (optional)
Directory to save migration files. Default: ./migrations/
Type: flag (optional)
Show what migrations would be generated without creating files.
✓ Generated migration: migrations/001_initial_schema.py ✓ Migration includes 3 tables: users, posts, comments ✓ File saved to: ./migrations/001_initial_schema.py
✓ Detected schema changes since last migration ✓ Generated migration: migrations/002_add_products_table.py ✓ Changes: CREATE TABLE products, ADD COLUMN category_id to users
✓ Created directory: ./db/migrations/ ✓ Generated migration: db/migrations/003_update_user_schema.py ✓ Changes: ALTER TABLE users ADD COLUMN last_login
Migration Preview: ================== File: migrations/004_add_user_preferences.py Operations: - ADD COLLECTION: user_preferences - UPDATE SCHEMA: users (add field: preferences) - CREATE INDEX: users.email (unique) Run without --dry-run to generate files.
Akron compares current database schema with the last migration to detect changes automatically.
Include data transformation logic in migration files for complex schema changes.
Every migration includes upgrade and downgrade functions for safe rollbacks.