From: Mike Bayer Date: Mon, 30 Jan 2012 17:36:10 +0000 (-0500) Subject: add docs for the standalone ops use case X-Git-Tag: rel_0_2_0~5 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c75454292d49bec65e3802e319f63e77bfc8a594;p=thirdparty%2Fsqlalchemy%2Falembic.git add docs for the standalone ops use case --- diff --git a/alembic/operations.py b/alembic/operations.py index 9efa830e..4b7b3ce4 100644 --- a/alembic/operations.py +++ b/alembic/operations.py @@ -11,17 +11,26 @@ class Operations(object): """Define high level migration operations. Each operation corresponds to some schema migration operation, - executed against a particular :class:`.MigrationContext`. - - Normally, the :class:`.MigrationContext` is created - within an ``env.py`` script via the - :meth:`.EnvironmentContext.configure` method. However, - the :class:`.Operations` object can also be used without - actually using the :class:`.EnvironmentContext` - class - only :class:`.MigrationContext`, which represents - connectivity to a single database, is needed - to use the directives. - + executed against a particular :class:`.MigrationContext` + which in turn represents connectivity to a database, + or a file output stream. + + While :class:`.Operations` is normally configured as + part of the :meth:`.EnvironmentContext.run_migrations` + method called from an ``env.py`` script, a standalone + :class:`.Operations` instance can be + made for use cases external to regular Alembic + migrations by passing in a :class:`.MigrationContext`:: + + from alembic.migration import MigrationContext + from alembic.operations import Operations + + conn = myengine.connect() + ctx = MigrationContext.configure(conn) + op = Operations(ctx) + + op.alter_column("t", "c", nullable=True) + """ def __init__(self, migration_context): """Construct a new :class:`.Operations`