ÿØÿà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@sddlZddlZddlmZddlmZmZmZmZm Z ddl m Z ddl m ZddlmZmZddlmZmZejeZd efd YZd efd YZd efdYZdefdYZdefdYZdS(iN(tcontextmanager(tMetaDatatTabletColumntStringtliteral_column(tMockEngineStrategy(turli(tcallablet EncodedIO(tddltutiltMigrationContextcBseZdZddZedddddddZedZdZ dZ dZ dZ dZ d Zdd Zd Zed Zed ZdZdZRS(sRepresent 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 Cs2||_||_||_|jd|_|jdt}|jd}|jdt|_|r|j||_|jdk st n ||_|jd|_ ||_ d|krt |jdptj|d|_n|jdtj|_|jdt|_|jd t|_|jd d |_}|jd d|_}t|ttd tddtd||_|jd|_tjj|||j|j ||j||_tj d|jj!j"|j r tj dntj d|jj#r'dnddS(Ntscripttas_sqlttransactional_ddlttransaction_per_migrationtfntoutput_encodingt output_buffert compare_typetcompare_server_defaultt version_tabletalembic_versiontversion_table_schemat version_numi tnullabletschemat starting_revsContext impl %s.sGenerating static SQLsWill assume %s DDL.t transactionalsnon-transactional($tenvironment_contexttoptstdialecttgetR tFalset_transaction_per_migrationt_stdout_connectiont connectiontNonetAssertionErrort_migrations_fnRR tsyststdoutRt_user_compare_typet_user_compare_server_defaultRRRRRRt_versiont_start_from_revR t DefaultImpltget_by_dialecttimpltlogtinfot __class__t__name__R( tselfR R%RRRRRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt__init__>sT            cCs|dkri}n|r'|j}ng|rNtj|}|j}n@|rytjd|}|j}n|stdnt||||S(sCreate a new :class:`.MigrationContext`. This is a factory method usually called by :meth:`.EnvironmentContext.configure`. :param connection: a :class:`~sqlalchemy.engine.Connection` to use for SQL execution in "online" mode. When present, is also used to determine the type of dialect in use. :param url: a string database url, or a :class:`sqlalchemy.engine.url.URL` object. The type of dialect to be used will be derived from this if ``connection`` is not passed. :param dialect_name: string name of a dialect, such as "postgresql", "mssql", etc. The type of dialect to be used will be derived from this if ``connection`` and ``url`` are not passed. :param opts: dictionary of options. Most other options accepted by :meth:`.EnvironmentContext.configure` are passed via this dictionary. s%s://s-Connection, url, or dialect_name is required.N(R&R tsqla_urltmake_urlt get_dialectt ExceptionR (tclsR%Rt dialect_nameR RR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt configurets   cs|jk}|s+td}|SjjsMtd}|Sjrrtfd}|SjjSdS(Ncss dVdS(N((((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt do_nothingscss dVdS(N((((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR?sc3s#jjdVjjdS(N(R1t emit_begint emit_commit((R6(sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt begin_commits (R#RR1RRtbindtbegin(R6t_per_migrationttransaction_nowR?RB((R6sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytbegin_transactions  cCsY|j}t|dkr"dSt|dkrMtjd|jn|dSdS(sReturn the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; if there are multiple branches present, an exception is raised. The :meth:`.MigrationContext.get_current_heads` should be preferred over this method going forward in order to be compatible with branch migration support. If this :class:`.MigrationContext` was configured in "offline" mode, that is with ``as_sql=True``, the ``starting_rev`` parameter is returned instead, if any. iisQVersion table '%s' has more than one head present; please use get_current_heads()N(tget_current_headstlenR&R t CommandErrorR(R6theads((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytget_current_revisions cCs|jrR|j}|dk r?|jr?|jj|j}ntj|ddS|jrmtjdn|j s}dSt d|j j |j jDS(sReturn a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revision`. However when multiple unmerged branches exist within the target database, the returned tuple will contain a value for each head. If this :class:`.MigrationContext` was configured in "offline" mode, that is with ``as_sql=True``, the ``starting_rev`` parameter is returned in a one-length tuple. If no version table is present, or if there are no revisions present, an empty tuple is returned. .. versionadded:: 0.7.0 tdefaultsECan't specify current_rev to context when using a database connectioncss|]}|dVqdS(iN((t.0trow((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys sN(((RR.R&R t get_revisiontrevisionR tto_tupleRJt_has_version_tablettupleR%texecuteR-tselect(R6tstart_from_rev((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRHs     cCs|jj|jdtdS(Nt checkfirst(R-tcreateR%tTrue(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_ensure_version_tablescCs"|jjj|j|j|jS(N(R%R t has_tableRR(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRSs cCsg|j}|j r*| r*|jnt||}x'|j||D]}|j|qLWdS(s}Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (either up or down). If no current branches include the revision, it is added as a new branch head. .. versionadded:: 0.7.0 N(RHRR[tHeadMaintainert _stamp_revstupdate_to_step(R6tscript_directoryRQRKthead_maintainertstep((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytstamps  cKs"|jj|j}|j r7| r7|jnt||}x|j||D]}|jdt~|jr|j r|j j |j nt jd||jr|jjd|jfn|j||j|WdQXqYW|jr|j r|j j|j ndS(s-Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. This function represents the "work" that will be done when :meth:`.MigrationContext.run_migrations` is called, typically from within the ``env.py`` script of the migration environment. The "work function" then provides an iterable of version callables and other version information which in the case of the ``upgrade`` or ``downgrade`` commands are the list of version scripts to invoke. Other commands yield nothing, in the case that a command wants to run some other operation against the database such as the ``current`` or ``stamp`` commands. :param \**kw: keyword arguments here will be passed to each migration callable, that is the ``upgrade()`` or ``downgrade()`` method within revision scripts. REs Running %ss -- Running %sN(R1tstart_migrationsRHRR[R]R(RGRZRKR-RYR%R2R3t static_outputt short_logt migration_fnR_tdrop(R6tkwRKRaRb((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytrun_migrationss      cCs|jj||dS(sExecute a SQL construct or string statement. The underlying execution mechanics are used, that is if this is "offline mode" the SQL is written to the output buffer, otherwise the SQL is emitted on the current SQLAlchemy connection. N(R1t_exec(R6tsqltexecution_options((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRUDs cs"fd}tjj|S(Ncsjj|dS(N(R1Rk(t constructt multiparamstparams(R6(sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytdumpPs(RtMockConnectionR (R6R%Rq((R6sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR$OscCs|jS(sReturn the current "bind". In online mode, this is an instance of :class:`sqlalchemy.engine.Connection`, and is suitable for ad-hoc execution of any kind of usage described in :ref:`sqlexpression_toplevel` as well as for usage with the :meth:`sqlalchemy.schema.Table.create` and :meth:`sqlalchemy.schema.MetaData.create_all` methods of :class:`~sqlalchemy.schema.Table`, :class:`~sqlalchemy.schema.MetaData`. Note that when "standard output" mode is enabled, this bind will be a "mock" connection handler that cannot return results and is only appropriate for a very limited subset of commands. (R%(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRCUscCs|jr|jjSdSdS(soReturn the :class:`.Config` used by the current environment, if any. .. versionadded:: 0.6.6 N(RtconfigR&(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRsjs  cCsi|jtkrtSt|jrV|j||||j|j}|dk rV|Sn|jj||S(N(R+R"RttypeR&R1R(R6tinspector_columntmetadata_columnt user_value((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt _compare_typevs   cCso|jtkrtSt|jrV|j|||||j|}|dk rV|Sn|jj||||S(N(R,R"Rtserver_defaultR&R1R(R6RuRvtrendered_metadata_defaulttrendered_column_defaultRw((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_compare_server_defaults"   N(R5t __module__t__doc__R&R7t classmethodR>R"RGRLRHR[RSRcRjRUR$tpropertyRCRsRxR|(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR s,- 6&   &    2  R]cBs5eZdZdZdZdZdZRS(cCs||_t||_dS(N(tcontexttsetRK(R6RRK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR7s cCs^||jkst|jj||jjj|jjjjdt d|dS(NRs'%s'( RKR'taddRR1RkR-tinserttvaluesR(R6tversion((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_insert_versions  cCs|jj||jjj|jjjj|jjjj t d|k}|jj r|j dkrt jd||jj|j fndS(Ns'%s'isOOnline migration expected to match one row when deleting '%s' in '%s'; %d found(RKtremoveRR1RkR-tdeletetwheretcRRRtrowcountR RJR(R6Rtret((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_delete_versions cCs||jkst|jj||jj||jjj|jjjj dt d|j |jjj j t d|k}|jj r|jdkrtjd|||jj|jfndS(NRs'%s'isWOnline migration expected to match one row when updating '%s' to '%s' in '%s'; %d found(RKR'RRRR1RkR-tupdateRRRRRRRR RJR(R6tfrom_tto_R((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_update_versions c Cs|j|jr;|j}tjd||j|n^|j|jrv|j}tjd||j|n#|j |jr|j |j\}}}tjd|||x|D]}|j|qW|j ||n|j |jr^|j |j\}}}tjd|||x|D]}|j|q4W|j ||n;|j|j\} } tjd| | |j | | dS(Nsbranch delete %ssnew branch insert %ss!merge, delete %s, update %s to %ss#unmerge, insert %s, update %s to %ssupdate %s to %s(tshould_delete_branchRKtdelete_version_numR2tdebugRtshould_create_branchtinsert_version_numRtshould_merge_branchestmerge_branch_identsRtshould_unmerge_branchestunmerge_branch_identstupdate_version_num( R6Rbtverst delete_revstupdate_from_revt update_to_revtdelrevt insert_revstinsrevRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR_s6      (R5R}R7RRRR_(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR]s    t MigrationStepcBs\eZedZedZedZedZedZdZ RS(cCs |jjS(N(RgR5(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytnamescCst||tS(N(t RevisionStepRZ(R<t revision_mapR ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytupgrade_from_scriptscCst||tS(N(RR"(R<RR ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytdowngrade_from_scriptscCs|j S(N(t is_upgrade(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt is_downgradescCs,d|jtj|jtj|jfS(Ns %s %s -> %s(RR tformat_as_commatfrom_revisionst to_revisions(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRfscCsF|jr;d|jtj|jtj|j|jfS|jSdS(Ns%s %s -> %s, %s(tdocRR RRRRf(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt__str__s  ( R5R}RRRRRRRfR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs RcBseZdZdZedZedZedZedZdZ dZ dZ d Z d Z d Zd Zed ZedZRS(cCsF||_||_||_|r3|jj|_n|jj|_dS(N(RRQRtmoduletupgradeRgt downgrade(R6RRQR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR7s    cCs1t|to0|j|jko0|j|jkS(N(t isinstanceRRQR(R6tother((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt__eq__&scCs |jjS(N(RQR(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR+scCs$|jr|jjS|jjfSdS(N(RRQt_all_down_revisions(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR/s  cCs$|jr|jjfS|jjSdS(N(RRQR(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR6s  cCst|jjdkS(Ni(RIRQR(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_has_scalar_down_revision=scCs|js tS|jj|kr#tS|jj}|s9tSt|dkr|jj|d}|jsntSt d|jj |jj |j dtD}t|j |j|jjgrtStSntSdS(Niicss|]}|jVqdS(N(RQ(RNtr((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys Sstcheck(RR"RQRRZRIRRPt_is_real_branch_pointRt_get_descendant_nodest get_revisionst _all_nextrevt intersectiont difference(R6RKtdownrevstdownrevt descendants((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRAs(    cCst|j|j}|rstd|jj|jj|dtD}tt|jj|}nt|j}t|dd!|d|jdfS(Ncss|]}|jVqdS(N(RQ(RNR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys vsRii( RRRRt_get_ancestor_nodesRR"tlistR(R6RKt other_headst ancestorsR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRqs cCst|j|jjg}|rytd|jj|jj|dtD}tt|jj|}n |j}|j d|d|dd!fS(Ncss|]}|jVqdS(N(RQ(RNR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys sRii( RRRQRRRR"RRR(R6RKRRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs ! cCs>|js tS|jj}|s#tS|j|s6tStSdS(N(RR"RQRRZR(R6RKR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  cCsN|js tS|jj}t|dkrJt|j|dkrJtStS(Ni(RR"RQRRIRRZ(R6RKR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  cCsE|js tS|jj}|jj|krAt|dkrAtStS(Ni(RR"RQRRIRZ(R6RKR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs   $cCs|jsO|j|jj}t|dks<tdt|d}n|jjd}|jrx||jjfS|jj|fSdS(Nis4Can't do an UPDATE because downrevision is ambiguousi(RRRQRRIR'RR(R6RKRt down_revision((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs   cCs |jjS(N(RQ(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs |jjS(N(RQ(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs(R5R}R7RRRRRRRRRRRRRRR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  0    t StampStepcBseZdZdZdZdZedZedZ edZ edZ dZ dZ d Zd Zd Zd Zd ZRS(cCsRtj|dd|_tj|dd|_||_||_|j|_dS(NRM(((R RRRRRt branch_movetstamp_revisionRg(R6RRRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR7s   cKsdS(N(R&(R6Ri((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCsUt|toT|j|jkoT|j|jkoT|j|jkoT|j|jkS(N(RRRt revisionsRRR(R6R((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs cCs|jS(N(R(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jS(N(R(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs&t|jdkst|jdS(Nii(RIRR'(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs&t|jdkst|jdS(Nii(RIRR'(R6((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCsNt|jdkstt|jdks6t|jd|jdfS(Nii(RIRR'R(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs+t|jdd!|jd|jdfS(Nii(RRR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs+|jd|jdt|jdd!fS(Nii(RRR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jo|jS(N(RR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jo|jS(N(RR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCst|jdkS(Ni(RIR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCst|jdkS(Ni(RIR(R6RK((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRsN(R5R}R7R&RRRRRRRRRRRRRRR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs         (tloggingR)t contextlibRt sqlalchemyRRRRRtsqlalchemy.engine.strategiesRtsqlalchemy.engineRR8t util.compatRR tR R t getLoggerR5R2tobjectR R]RRR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyts  (S%