From 500bb6bfbc52d463cf9a87cb1ce5c5de64eb4cf0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 24 Jan 2012 02:24:01 -0500 Subject: [PATCH] add a thing about migration tools --- doc/build/core/schema.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/build/core/schema.rst b/doc/build/core/schema.rst index 708a9e9091..d1e2c2d78b 100644 --- a/doc/build/core/schema.rst +++ b/doc/build/core/schema.rst @@ -250,6 +250,30 @@ To enable the "check first for the table existing" logic, add the employees.create(engine, checkfirst=True) employees.drop(engine, checkfirst=False) +Altering Schemas through Migrations +----------------------------------- + +While SQLAlchemy directly supports emitting CREATE and DROP statements for schema +constructs, the ability to alter those constructs, usually via the ALTER statement +as well as other database-specific constructs, is outside of the scope of SQLAlchemy +itself. While it's easy enough to emit ALTER statements and similar by hand, +such as by passing a string to :meth:`.Connection.execute` or by using the +:class:`.DDL` construct, it's a common practice to automate the maintenance of +database schemas in relation to application code using schema migration tools. + +There are two major migration tools available for SQLAlchemy: + +* `Alembic `_ - Written by the author of SQLAlchemy, + Alembic features a highly customizable environment and a minimalistic usage pattern, + supporting such features as transactional DDL, automatic generation of "candidate" + migrations, an "offline" mode which generates SQL scripts, and support for branch + resolution. +* `SQLAlchemy-Migrate `_ - The original + migration tool for SQLAlchemy, SQLAlchemy-Migrate is widely used and continues + under active development. SQLAlchemy-Migrate includes features such as + SQL script generation, ORM class generation, ORM model comparison, and extensive + support for SQLite migrations. + .. _metadata_binding: Binding MetaData to an Engine or Connection -- 2.47.2