%PDF- %PDF-
Direktori : /opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/ |
Current File : //opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyc |
� �M!Vc @ s d d l Z d d l Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z m Z d d l m Z m Z e j e � Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( i����N( t contextmanager( t MetaDatat Tablet Columnt Stringt literal_column( t MockEngineStrategy( t urli ( t callablet EncodedIO( t ddlt utilt MigrationContextc B s� e Z d Z d d � Z e d d d d d d d � � Z e d � Z d � Z d � Z d � Z d � Z d � Z d � Z d d � Z d � Z e d � � Z e d � � Z d � Z d � Z RS( s� Represent the database state made available to a migration script. :class:`.MigrationContext` is the front end to an actual database connection, or alternatively a string output stream given a particular database dialect, from an Alembic perspective. When inside the ``env.py`` script, the :class:`.MigrationContext` is available via the :meth:`.EnvironmentContext.get_context` method, which is available at ``alembic.context``:: # from within env.py script from alembic import context migration_context = context.get_context() For usage outside of an ``env.py`` script, such as for utility routines that want to check the current version in the database, the :meth:`.MigrationContext.configure` method to create new :class:`.MigrationContext` objects. For example, to get at the current revision in the database using :meth:`.MigrationContext.get_current_revision`:: # in any application, outside of an env.py script from alembic.migration import MigrationContext from sqlalchemy import create_engine engine = create_engine("postgresql://mydatabase") conn = engine.connect() context = MigrationContext.configure(conn) current_rev = context.get_current_revision() The above context can also be used to produce Alembic migration operations with an :class:`.Operations` instance:: # in any application, outside of the normal Alembic environment from alembic.operations import Operations op = Operations(context) op.alter_column("mytable", "somecolumn", nullable=True) c C s2 | | _ | | _ | | _ | j d � | _ | j d t � } | j d � } | j d t � | _ | r� | j | � | _ | j d k s� t � n | | _ | j d � | _ | | _ d | k r� t | j d � p� t j | d � | _ n | j d t j � | _ | j d t � | _ | j d t � | _ | j d d � | _ } | j d d � | _ } t | t � t d t d � d t �d | �| _ | j d � | _ t j j | � | | j | j | | j | � | _ t j d | j j! j"