Welcome to Alembic’s documentation!#
Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.
- Front Matter
- Tutorial
- Auto Generating Migrations- What does Autogenerate Detect (and what does it not detect?)
- Autogenerating Multiple MetaData collections
- Controlling What to be Autogenerated
- Comparing and Rendering Types
- Applying Post Processing and Python Code Formatters to Generated Revisions
- Running Alembic Check to test for new upgrade operations
 
- Generating SQL Scripts (a.k.a. “Offline Mode”)
- The Importance of Naming Constraints
- Running “Batch” Migrations for SQLite and Other Databases
- Working with Branches
- Operation Reference- AbstractOperations
- Operations- Operations.add_column()
- Operations.alter_column()
- Operations.batch_alter_table()
- Operations.bulk_insert()
- Operations.create_check_constraint()
- Operations.create_exclude_constraint()
- Operations.create_foreign_key()
- Operations.create_index()
- Operations.create_primary_key()
- Operations.create_table()
- Operations.create_table_comment()
- Operations.create_unique_constraint()
- Operations.drop_column()
- Operations.drop_constraint()
- Operations.drop_index()
- Operations.drop_table()
- Operations.drop_table_comment()
- Operations.execute()
- Operations.f()
- Operations.get_bind()
- Operations.get_context()
- Operations.implementation_for()
- Operations.inline_literal()
- Operations.invoke()
- Operations.register_operation()
- Operations.rename_table()
- Operations.run_async()
 
- BatchOperations- BatchOperations.add_column()
- BatchOperations.alter_column()
- BatchOperations.create_check_constraint()
- BatchOperations.create_exclude_constraint()
- BatchOperations.create_foreign_key()
- BatchOperations.create_index()
- BatchOperations.create_primary_key()
- BatchOperations.create_table_comment()
- BatchOperations.create_unique_constraint()
- BatchOperations.drop_column()
- BatchOperations.drop_constraint()
- BatchOperations.drop_index()
- BatchOperations.drop_table_comment()
- BatchOperations.execute()
 
 
- Cookbook- Building an Up to Date Database from Scratch
- Conditional Migration Elements
- Sharing a Connection across one or more programmatic migration commands
- Replaceable Objects
- Rudimental Schema-Level Multi Tenancy for PostgreSQL, MySQL, Other Databases
- Don’t Generate Empty Migrations with Autogenerate
- Don’t emit DROP INDEX when the table is to be dropped as well
- Don’t generate any DROP TABLE directives with autogenerate
- Apply Custom Sorting to Table Columns within CREATE TABLE
- Add IF [NOT] EXISTS to CREATE/DROP operations
- Don’t emit CREATE TABLE statements for Views
- Run Multiple Alembic Environments from one .ini file
- Print Python Code to Generate Particular Database Tables
- Run Alembic Operation Objects Directly (as in from autogenerate)
- Test current database revision is at head(s)
- Using Asyncio with Alembic
- Data Migrations - General Techniques
- Extend CommandLinewith custom commands
 
- API Details- Overview
- Runtime Objects
- Configuration
- Commands
- Operation Directives
- Autogeneration
- Script Directory
- DDL Internals- AddColumn
- AlterColumn
- AlterTable
- ColumnComment
- ColumnDefault
- ColumnName
- ColumnNullable
- ColumnType
- ComputedColumnDefault
- DropColumn
- IdentityColumnDefault
- RenameTable
- add_column()
- alter_column()
- alter_table()
- drop_column()
- format_column_name()
- format_server_default()
- format_table_name()
- format_type()
- quote_dotted()
- visit_add_column()
- visit_column_default()
- visit_column_name()
- visit_column_nullable()
- visit_column_type()
- visit_computed_column()
- visit_drop_column()
- visit_identity_column()
- visit_rename_table()
- DefaultImpl
- ImplMeta
- Params
- MySQL
- MS-SQL
- Postgresql
- SQLite
 
 
- Changelog- 1.16.2
- 1.16.1
- 1.16.0
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.1
- 1.14.0
- 1.13.3
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.3
- 1.11.2
- 1.11.1
- 1.11.0
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.1
- 1.8.0
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
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