ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ M!Vc@sMddlmZddlmZddlmZdejfdYZdS(i(t Operationsi(tMigrationContext(tutiltEnvironmentContextcBs"eZdZeZeZeZdZdZdZ dZ dZ dZ dZ dZd Zd Zd Zed Zeeeeeeeeeeeeeeeeeeed dddedZdZedZdZdZdZdZdZRS(su A configurational facade made available in an ``env.py`` script. The :class:`.EnvironmentContext` acts as a *facade* to the more nuts-and-bolts objects of :class:`.MigrationContext` as well as certain aspects of :class:`.Config`, within the context of the ``env.py`` script that is invoked by most Alembic commands. :class:`.EnvironmentContext` is normally instantiated when a command in :mod:`alembic.command` is run. It then makes itself available in the ``alembic.context`` module for the scope of the command. From within an ``env.py`` script, the current :class:`.EnvironmentContext` is available by importing this module. :class:`.EnvironmentContext` also supports programmatic usage. At this level, it acts as a Python context manager, that is, is intended to be used using the ``with:`` statement. A typical use of :class:`.EnvironmentContext`:: from alembic.config import Config from alembic.script import ScriptDirectory config = Config() config.set_main_option("script_location", "myapp:migrations") script = ScriptDirectory.from_config(config) def my_function(rev, context): '''do something with revision "rev", which will be the current database revision, and "context", which is the MigrationContext that the env.py will create''' with EnvironmentContext( config, script, fn = my_function, as_sql = False, starting_rev = 'base', destination_rev = 'head', tag = "sometag" ): script.run_env() The above script will invoke the ``env.py`` script within the migration environment. If and when ``env.py`` calls :meth:`.MigrationContext.run_migrations`, the ``my_function()`` function above will be called by the :class:`.MigrationContext`, given the context itself as well as the current revision in the database. .. note:: For most API usages other than full blown invocation of migration scripts, the :class:`.MigrationContext` and :class:`.ScriptDirectory` objects can be created and used directly. The :class:`.EnvironmentContext` object is *only* needed when you need to actually invoke the ``env.py`` module present in the migration environment. cKs||_||_||_dS(s^Construct a new :class:`.EnvironmentContext`. :param config: a :class:`.Config` instance. :param script: a :class:`.ScriptDirectory` instance. :param \**kw: keyword options that will be ultimately passed along to the :class:`.MigrationContext` when :meth:`.EnvironmentContext.configure` is called. N(tconfigtscriptt context_opts(tselfRRtkw((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyt__init__Ss  cCs|j|S(sEstablish a context which provides a :class:`.EnvironmentContext` object to env.py scripts. The :class:`.EnvironmentContext` will be made available as ``from alembic import context``. (t_install_proxy(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyt __enter__as cOs|jdS(N(t _remove_proxy(RtargR((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyt__exit__mscCs|jjdtS(s%Return True if the current migrations environment is running in "offline mode". This is ``True`` or ``False`` depending on the the ``--sql`` flag passed. This function does not require that the :class:`.MigrationContext` has been configured. tas_sql(RtgettFalse(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytis_offline_modeps cCs|jjjS(sReturn True if the context is configured to expect a transactional DDL capable backend. This defaults to the type of database in use, and can be overridden by the ``transactional_ddl`` argument to :meth:`.configure` This function requires that a :class:`.MigrationContext` has first been made available via :meth:`.configure`. (t get_contexttimplttransactional_ddl(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytis_transactional_ddl}s cCs |j S(N(R(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytrequires_connectionscCs|jjdS(sReturn the hex identifier of the 'head' script revision. If the script directory has multiple heads, this method raises a :class:`.CommandError`; :meth:`.EnvironmentContext.get_head_revisions` should be preferred. This function does not require that the :class:`.MigrationContext` has been configured. .. seealso:: :meth:`.EnvironmentContext.get_head_revisions` thead(Rtas_revision_number(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_head_revisions cCs|jjdS(s:Return the hex identifier of the 'heads' script revision(s). This returns a tuple containing the version number of all heads in the script directory. This function does not require that the :class:`.MigrationContext` has been configured. .. versionadded:: 0.7.0 theads(RR(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_head_revisionss cCsa|jdk r(|jj|jjSd|jkrN|jj|jdStjddS(sTReturn the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. Returns ``None`` if no value is available or was configured. This function does not require that the :class:`.MigrationContext` has been configured. t starting_revs+No starting revision argument is available.N( t_migration_contexttNoneRRRt_start_from_revRRt CommandError(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_starting_revision_arguments   cCs|jj|jdS(sGet the 'destination' revision argument. This is typically the argument passed to the ``upgrade`` or ``downgrade`` command. If it was specified as ``head``, the actual version number is returned; if specified as ``base``, ``None`` is returned. This function does not require that the :class:`.MigrationContext` has been configured. tdestination_rev(RRR(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_revision_arguments cCs|jjddS(sgReturn the value passed for the ``--tag`` argument, if any. The ``--tag`` argument is not used directly by Alembic, but is available for custom ``env.py`` configurations that wish to use it; particularly for offline generation scripts that wish to generate tagged filenames. This function does not require that the :class:`.MigrationContext` has been configured. .. seealso:: :meth:`.EnvironmentContext.get_x_argument` - a newer and more open ended system of extending ``env.py`` scripts via the command line. ttagN(RRR(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_tag_argumentscCsS|jjdk r*|jjjp$g}ng}|rOtd|D}n|S(sReturn the value(s) passed for the ``-x`` argument, if any. The ``-x`` argument is an open ended flag that allows any user-defined value or values to be passed on the command line, then available here for consumption by a custom ``env.py`` script. The return value is a list, returned directly from the ``argparse`` structure. If ``as_dictionary=True`` is passed, the ``x`` arguments are parsed using ``key=value`` format into a dictionary that is then returned. For example, to support passing a database URL on the command line, the standard ``env.py`` script can be modified like this:: cmd_line_url = context.get_x_argument( as_dictionary=True).get('dbname') if cmd_line_url: engine = create_engine(cmd_line_url) else: engine = engine_from_config( config.get_section(config.config_ini_section), prefix='sqlalchemy.', poolclass=pool.NullPool) This then takes effect by running the ``alembic`` script as:: alembic -x dbname=postgresql://user:pass@host/dbname upgrade head This function does not require that the :class:`.MigrationContext` has been configured. .. versionadded:: 0.6.0 .. seealso:: :meth:`.EnvironmentContext.get_tag_argument` :attr:`.Config.cmd_opts` css!|]}|jddVqdS(t=iN(tsplit(t.0R ((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pys sN(Rtcmd_optsRtxtdict(Rt as_dictionarytvalue((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_x_arguments)tupgradest downgradessop.ssa.c Ks|j}|tk r"||dRRH((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRJsR                             cKs0tj|j|jj|WdQXdS(sRun migrations as determined by the current command line configuration as well as versioning information present (or not) in the current database connection (if one is present). The function accepts optional ``**kw`` arguments. If these are passed, they are sent directly to the ``upgrade()`` and ``downgrade()`` functions within each target revision file. By modifying the ``script.py.mako`` file so that the ``upgrade()`` and ``downgrade()`` functions accept arguments, parameters can be passed here so that contextual information, usually information to identify a particular database in use, can be passed from a custom ``env.py`` script to the migration functions. This function requires that a :class:`.MigrationContext` has first been made available via :meth:`.configure`. N(RtcontextRRtrun_migrations(RR((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRLscCs|jj|d|dS(sExecute the given SQL using the current change context. The behavior of :meth:`.execute` is the same as that of :meth:`.Operations.execute`. Please see that function's documentation for full detail including caveats and limitations. This function requires that a :class:`.MigrationContext` has first been made available via :meth:`.configure`. texecution_optionsN(Rtexecute(RtsqlRM((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRNs cCs|jjj|dS(sEmit text directly to the "offline" SQL stream. Typically this is for emitting comments that start with --. The statement is not treated as a SQL execution, no ; or batch separator is added, etc. N(RRt static_output(Rttext((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRP.s cCs|jjS(s[Return a context manager that will enclose an operation within a "transaction", as defined by the environment's offline and transactional DDL settings. e.g.:: with context.begin_transaction(): context.run_migrations() :meth:`.begin_transaction` is intended to "do the right thing" regardless of calling context: * If :meth:`.is_transactional_ddl` is ``False``, returns a "do nothing" context manager which otherwise produces no transactional state or directives. * If :meth:`.is_offline_mode` is ``True``, returns a context manager that will invoke the :meth:`.DefaultImpl.emit_begin` and :meth:`.DefaultImpl.emit_commit` methods, which will produce the string directives ``BEGIN`` and ``COMMIT`` on the output stream, as rendered by the target backend (e.g. SQL Server would emit ``BEGIN TRANSACTION``). * Otherwise, calls :meth:`sqlalchemy.engine.Connection.begin` on the current online connection, which returns a :class:`sqlalchemy.engine.Transaction` object. This object demarcates a real transaction and is itself a context manager, which will roll back if an exception is raised. Note that a custom ``env.py`` script which has more specific transactional needs can of course manipulate the :class:`~sqlalchemy.engine.Connection` directly to produce transactional state in "online" mode. (Rtbegin_transaction(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRR9s,cCs%|jdkrtdn|jS(sReturn the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception. s#No context has been configured yet.N(RRt Exception(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRgscCs |jjS(s3Return the current 'bind'. In "online" mode, this is the :class:`sqlalchemy.engine.Connection` currently being used to emit SQL to the database. This function requires that a :class:`.MigrationContext` has first been made available via :meth:`.configure`. (Rtbind(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_bindss cCs |jjS(N(RR(R((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pytget_impls(t__name__t __module__t__doc__RRRRR R RRRRRRR"R$R&RR/RJRLRNRPRRRRURV(((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyRs`=          4   . N(t operationsRt migrationRtRtModuleClsProxyR(((sL/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/environment.pyts