ÿØÿà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 Cs||_||_||_|jd|_|jdt}|jd}|jdt|_|r~|j||_n ||_|jd|_ ||_ d|krt |jdpt j |d|_n|jdt j |_|jdt|_|jd t|_|jd d |_}|jd d|_}t|ttd tddtd||_|jd|_tjj|||j|j ||j||_tjd|jj j!|j rtjdntjd|jj"rdnddS(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 connectiont_migrations_fnRR tsyststdoutRt_user_compare_typet_user_compare_server_defaultRtNoneRRRRRt_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(R0t emit_begint emit_commit((R5(sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt begin_commits (R#RR0RRtbindtbegin(R5t_per_migrationttransaction_nowR>RA((R5sJ/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(R5theads((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_tupleRIt_has_version_tablettupleR%texecuteR,tselect(R5tstart_from_rev((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRGs     cCs|jj|jdtdS(Nt checkfirst(R,tcreateR%tTrue(R5((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(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRRs 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(RGRRZtHeadMaintainert _stamp_revstupdate_to_step(R5tscript_directoryRPRJthead_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. RDs Running %ss -- Running %sN(R0tstart_migrationsRGRRZR\R&RFRYRJR,RXR%R1R2t static_outputt short_logt migration_fnR^tdrop(R5tkwRJR`Ra((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(R0t_exec(R5tsqltexecution_options((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRTDs cs"fd}tjj|S(Ncsjj|dS(N(R0Rj(t constructt multiparamstparams(R5(sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytdumpPs(RtMockConnectionR (R5R%Rp((R5sJ/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%(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRBUscCs|jr|jjSdSdS(soReturn the :class:`.Config` used by the current environment, if any. .. versionadded:: 0.6.6 N(RtconfigR+(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRrjs  cCsi|jtkrtSt|jrV|j||||j|j}|dk rV|Sn|jj||S(N(R)R"RttypeR+R0R(R5tinspector_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+R0R(R5RtRutrendered_metadata_defaulttrendered_column_defaultRv((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_compare_server_defaults"   N(R4t __module__t__doc__R+R6t classmethodR=R"RFRKRGRZRRRbRiRTR$tpropertyRBRrRwR{(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR s,- 6&   &    2  R\cBs5eZdZdZdZdZdZRS(cCs||_t||_dS(N(tcontexttsetRJ(R5RRJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR6s cCsI|jj||jjj|jjjjdtd|dS(NRs'%s'( RJtaddRR0RjR,tinserttvaluesR(R5tversion((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(RJtremoveRR0RjR,tdeletetwheretcRRRtrowcountR RIR(R5Rtret((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt_delete_versions cCs|jj||jj||jjj|jjjjdt 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(RJRRRR0RjR,tupdateRRRRRRRR RIR(R5tfrom_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_branchRJtdelete_version_numR1tdebugRtshould_create_branchtinsert_version_numRtshould_merge_branchestmerge_branch_identsRtshould_unmerge_branchestunmerge_branch_identstupdate_version_num( R5Ratverst delete_revstupdate_from_revt update_to_revtdelrevt insert_revstinsrevRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR^s6      (R4R|R6RRRR^(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR\s    t MigrationStepcBs\eZedZedZedZedZedZdZ RS(cCs |jjS(N(RfR4(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pytnamescCst||tS(N(t RevisionStepRY(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(R5((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(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRescCsF|jr;d|jtj|jtj|j|jfS|jSdS(Ns%s %s -> %s, %s(tdocRR RRRRe(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt__str__s  ( R4R|RRR~RRRReR(((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(RRPRtmoduletupgradeRft downgrade(R5RRPR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR6s    cCs1t|to0|j|jko0|j|jkS(N(t isinstanceRRPR(R5tother((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyt__eq__&scCs |jjS(N(RPR(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR+scCs$|jr|jjS|jjfSdS(N(RRPt_all_down_revisions(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR/s  cCs$|jr|jjfS|jjSdS(N(RRPR(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR6s  cCst|jjdkS(Ni(RHRPR(R5((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(RP(RMtr((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys Sstcheck(RR"RPRRYRHRROt_is_real_branch_pointRt_get_descendant_nodest get_revisionst _all_nextrevt intersectiont difference(R5RJtdownrevstdownrevt 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(RP(RMR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys vsRii( RRRRt_get_ancestor_nodesRR"tlistR(R5RJt 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(RP(RMR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pys sRii( RRRPRRRR"RRR(R5RJRRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs ! cCs>|js tS|jj}|s#tS|j|s6tStSdS(N(RR"RPRRYR(R5RJR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  cCsN|js tS|jj}t|dkrJt|j|dkrJtStS(Ni(RR"RPRRHRRY(R5RJR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  cCsE|js tS|jj}|jj|krAt|dkrAtStS(Ni(RR"RPRRHRY(R5RJR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs   $cCsn|js1|j|jj}t|d}n|jjd}|jrZ||jjfS|jj|fSdS(Ni(RRRPRRR(R5RJRt down_revision((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs  cCs |jjS(N(RP(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs |jjS(N(RP(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs(R4R|R6RRRRRRRRRRRRRRR(((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(NRL(((R RQRRRt branch_movetstamp_revisionRf(R5RRRR((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyR6s   cKsdS(N(R+(R5Rh((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(R5R((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs cCs|jS(N(R(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jS(N(R(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs |jdS(Ni(R(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs |jdS(Ni(R(R5((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jd|jdfS(Ni(RR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs+t|jdd!|jd|jdfS(Nii(RRR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs+|jd|jdt|jdd!fS(Nii(RRR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jo|jS(N(RR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCs|jo|jS(N(RR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCst|jdkS(Ni(RHR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRscCst|jdkS(Ni(RHR(R5RJ((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRsN(R4R|R6R+RRRRRRRRRRRRRRR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyRs         (tloggingR't contextlibRt sqlalchemyRRRRRtsqlalchemy.engine.strategiesRtsqlalchemy.engineRR7t util.compatRR tR R t getLoggerR4R1tobjectR R\RRR(((sJ/opt/alt/python27/lib/python2.7/site-packages/alembic/runtime/migration.pyts  (S%