XׯdQddlZddlZddlZddlZddlmZGddeZGddeZ GddeZ Gd d eZ dS) N) log_debugceZdZdS)NotSupportedErrorN)__name__ __module__ __qualname__..\modules\migration.pyrrsDr rceZdZdZdZdZeeeZdZdZ eee Z dZ ee Z dZ dZd Zd Zd Zd Zd ZdZdZdZdS)MigrationTargetcZ||_d|_d|_||dSN)state_rdbmspassword_set_connectionselfr connections r __init__zMigrationTarget.__init__#s1    Z(((((r c|jSrrrs r _get_rdbmszMigrationTarget._get_rdbms* ,r cX|jdkrtd|jz||_dS)NMysqlzUnsupported target RDBMS "%s")name ValueErrorr)rrdbmss r _set_rdbmszMigrationTarget._set_rdbms,s0 : >KLL L r c|jjSrr targetCatalogrs r _get_catalogzMigrationTarget._get_catalog3 4:#;;r c||j_dSrr$rcatalogs r _set_catalogzMigrationTarget._set_catalog5s#*    r c|jjSr)rtargetConnectionrs r _get_connectionzMigrationTarget._get_connection: z**r c|jr |jjstd||j_|jj|_dSNzInvalid connection object)driverownerr rr-rrrs r rzMigrationTarget._set_connection?sD  : (9(? :899 9&0 # '- r cn||j|jpddSNT) module_feconnectrrrs r checkConnectionzMigrationTarget.checkConnectionEs0   $-2E2FFFtr c||j|j_t j|j_|jjj |jj_ |jjj |jj_ |jjj |jj_ |jjj |jj_ dSr) r8getServerVersionrrtargetDBVersiongrtclasses GrtVersion targetVersionr majorNumber minorNumber releaseNumberrs r checkVersionzMigrationTarget.checkVersionIs%)^^%5%5%F%Ft%W%W "#&;#9#9#;#;  (, (B(G  %/3z/I/U  ,/3z/I/U  ,151K1Y  ...r cdtjj|j|jpdSNr7)r>modules DbMySQLFEr9rrrs r r9zMigrationTarget.connectRs&{$,,T_dm>QrRRRr cTtjj|jSr)r>rHrI disconnectrrs r rKzMigrationTarget.disconnectUs{$//@@@r c$tjjSr)r>rHrIrs r r8zMigrationTarget.module_feX {$$r c$tjjSr)r>rH DbMySQLRErs r module_rezMigrationTarget.module_re[rMr c$tjjSr)r>rHDbMySQLMigrationrs r module_migrationz MigrationTarget.module_migration^s {++r c$tjjSr)r>rHDbMySQLrs r module_dbzMigrationTarget.module_dbas {""r c|rB||j}||SdSr)r:r8getOSrrK)ros_names r get_oszMigrationTarget.get_osdsO    ! ! nn&&,,T_==G OO   Ntr N)rrrrrr"propertyr!r&r+r*r.rrr:rEr9rKr8rPrSrVrZr r r r r "s:)))-,, HZ , ,E;;;+++h|\22G+++/**J... ZZZSSSAAA%%%%%%,,,###r r ceZdZdZdZdZeeeZdZeeZ dZ dZ ee e Z dZ dZee eZd Zd ZeeeZd Zd ZeeeZd ZdZdZdZdZdZdZdZdZedZdZ gfdZ!edZ"dZ#dZ$dZ%dZ&dZ'dZ(d Z)d!Z*d"Z+d#Z,d$Z-d%Z.d&S)'MigrationSourcec||_d|_d|_d|_d|_d|_d|_d|_||dSr) rr_rev_eng_module_migration_module _db_module _catalog_namer migrationrrs r rzMigrationSource.__init__osW  #!%!  Z(((((r c|jSrrrs r rzMigrationSource._get_rdbms|rr c||_d|_d|_d|_t t jD]}tt j|}t|dr| |j krJ|j }| drt|dr||_| drt|dr||_| drt|dr||_|jr|jr|jstd|j z|j|_dS)NgetTargetDBMSNameDbreverseEngineermigrateCatalogfullyQualifiedObjectNamezSource RDBMS "%s" not supported)rr_rar`dirr>rHgetattrhasattrrfrr startswithr rc)rr!mnamemodrs r r"zMigrationSource._set_rdbms~sP #!%%% & &E#+u--C3 344 8M8M8O8OSXS]8]8]KLL L/r c|jjSrr sourceCatalogrs r r&zMigrationSource._get_catalogr'r c|jjSr)rsourceConnectionrs r r.zMigrationSource._get_connectionr/r c|jr |jjstd||j_||jjdSr1)r2r3r rrur"r4s r rzMigrationSource._set_connectionsQ  : (9(? :899 9&0 #  )/00000r c|jjSr)rselectedSchemataNamesrs r _get_selected_schemataz&MigrationSource._get_selected_schematas z//r c|jj|D]!}|jj|"dSr)rrx remove_allappend)rnamesrs r _set_selected_schemataz&MigrationSource._set_selected_schematasN (33555 : :D J , 3 3D 9 9 9 9 : :r c||_dSrrb)rrs r _set_selected_catalogz%MigrationSource._set_selected_catalogs!r c|jSrrrs r _get_selected_catalogz%MigrationSource._get_selected_catalogs !!r c|jjSrr ignoreListrs r _get_ignore_listz MigrationSource._get_ignore_lists z$$r c||j_dSrr)rilists r _set_ignore_listz MigrationSource._set_ignore_lists % r cT|j|j|jpddSr6)r_r9rrrs r r9zMigrationSource.connects) $$T_dm6IrJJJtr c@|j|jSr)r_rKrrs r rKzMigrationSource.disconnects#..t???r cr||j|j_dSr)rPr<rrsourceDBVersionrs r rEzMigrationSource.checkVersions,%)^^%5%5%F%Ft%W%W """r c@|j|jSr)r_getCatalogNamesrrs r rzMigrationSource.getCatalogNamess#33DODDDr cF|j|j|pdSrG)r_getSchemaNamesrr)s r rzMigrationSource.getSchemaNamess!#224?GMrRRRr cH|j|j|pd|SrG)r_ getTableNamesr)rr*schemas r rzMigrationSource.getTableNamess$#11$/7=bRXYYYr c|jSr)r_rs r rPzMigrationSource.module_res ##r c|jSr)r`rs r rSz MigrationSource.module_migrations %%r c|jSr)rars r rVzMigrationSource.module_dbs r c|jjSr)rsourceSchemataNamesrs r schemaNameszMigrationSource.schemaNamess z--r cnt|jdr|j|jSdS)NgetDriverDBMSNamer7)rmr_rrrs r rz!MigrationSource.getDriverDBMSNames7 4')< = = K'99$/JJ Jrr c tjdd||jjdkrtjdd|jj|}|rt| |}|r7tj dd t|ztt| |p|}||_tjddd}d t|d zz }|D]}|stj|d |z||}|D]Y}|s|jj|j|d |j|Z|d |zz }n|jjdkrJtjdd|d}|rt| |} | r7tj dd t| ztt| | p|d}g|_|jj|D]V}|jj|jdd |j|Wntg|_|jj|dD]9}|jj|j|:tjd ddS)zmFetch list of schema names in catalog.schema format and stores them in the migration.sourceSchemataNames nodegzChecking connection...rg?zFetching catalog names...z'The following catalogs were not found: , zFetching schema names...g?g|=z Fetching schema names from %s....g?r7z'The following schemas where not found: defFinishedN)r> send_progressr9r!doesSupportCatalogsrrr{rset difference send_warningjoinlist_catalog_nameslenrr|raquoteIdentifier) ronly_these_catalogs catalog_namesinexistent_catalogsaccumulated_progressstep_progress_sharer* schema_namesrinexistent_schematas r doFetchSchemaNamesz"MigrationSource.doFetchSchemaNamess9 #7888  : )A - -  c#> ? ? ? J * 5 5 7 7 7 0022M" y&)*=&>&>&I&I-&X&X#&w$%NQUQZQZ[_`s[t[tQuQu%uvvv $S)<%=%=%H%HI\%]%] ^ ^ xbfbvbvbxbx "/D   c#= > > >#& "%]););e)C"D ( B B!"68Z]d8deee#227;; *YYF!! J299T_EdEdelEmEmEmEmoso~pOpOPVpWpWpW;XYYYY$.A(AA$$ BZ +q 0 0  c#= > > >..r22L" z&)*=&>&>&I&I,&W&W#&w$%NQUQZQZ[_`s[t[tQuQu%uvvv#C(;$<$<$G$GH[$\$\]]ybfbubuvxbyby "$D  J * 5 5 7 7 7& S S .55A`A`afAgAgAgAgimixjIjIJPjQjQjQ7RSSSS S#%D  J * 5 5 7 7 7--b11 _ _ .55do6U6UV\6]6]^^^^ #z*****r c\t|jdr't|j}ngd}|dd}|ddD]V}|d}|jjD]?}t ||d}|r*t|dkr||n@W|S)NgetSupportedObjectTypes))tableszdb.TableTables)viewszdb.ViewViews)routinesz db.RoutineRoutines) routineGroupszdb.RoutineGroupzRoutine Groups)synonymsz db.SynonymSynonyms)structuredTypeszdb.StructuredTypezStructured Types) sequencesz db.Sequence SequencesrF) rmr_rrr*schematarlrr|)rallTypes supporteditemtrobjectss r supportedObjectTypesz$MigrationSource.supportedObjectTypess 4')B C C CD0HHJJKKHHCCCHRaRL QRRL  DQA,/  !&!U33s7||a//$$T***Er cg}|jjD]:}t||}|D]%}|d|jz|j&;|S)Nz%s.%s)r*rrlr|r)rotypelrrobjs r allObjectsOfTypez MigrationSource.allObjectsOfType4sc l+ : :Ffe,,G : :6;.9999 :r cg}|jD]6}|d\}}}||kr||7|SN:)rsplitr|)rrr ignore_specrseprs r availableObjectsOfTypez&MigrationSource.availableObjectsOfType<sO ?  K%++C00KAsCEzz r cg}|jjD]X}t||}|D]C}|d|jd|j}||jvr$||jd|jDY|S)Nrr)r*rrlrrr|)rrrrrrrs r selectedObjectsOfTypez%MigrationSource.selectedObjectsOfTypeDs l+ @ @Ffe,,G @ @,1EE6;;;I do55HH SXX>??? @r c  tttt|jD]-}|j||dzr|j|=.|D]!}|j|d|"dSrreversedrrangerrrnr|)rriglistirs r setIgnoredObjectsOfTypez'MigrationSource.setIgnoredObjectsOfTypeOs$uS%9%9::;;<< ' 'Aq!,,U3Y77 'OA& < 2 2 2 2 2 3 3r cd|z|jvS)Nr)r)rrs r isObjectTypeIgnoredz#MigrationSource.isObjectTypeIgnored_s~00r cbd|z|jvs |d|jjd|j|jvrdSdS)NrrrTF)rr3r)rrrs r isObjectIgnoredzMigrationSource.isObjectIgnoredbsE E>T_ , ,eeeSY^^^UXU]U]0^bfbq0q0q4ur c|tjdd|jd|j|j|j|j|j|j j |j _ dS)zUPerform reverse engineering of selected schemas into the migration.sourceCatalog nodezReverse engineering rz from N) r9r> send_inforrxselectedCatalogNamer_rhrrapplicationDatarsrs r rhzMigrationSource.reverseEngineergs  $))DD^:_:_:_:_aeayayz{{{#'#7#G#GY]YqswtNPTPZPj$k$k    r crt|jdr!|j|jdSdS)NresetProgressFlags)rmr_rrrs r rz"MigrationSource.resetProgressFlagsnsD 4')= > > C   1 1$/ B B B B B C Cr cft|jdr|jdSdS)Ncleanup)rmr_rrs r rzMigrationSource.cleanuprs< 4' 3 3 +  ( ( * * * * * + +r ct|dr,||jSdS)NrX)rmrPrXrrs r rZzMigrationSource.get_osvsC 4>>##W - - >>##))$/:: :4r cZ||jSr)rPgetSourceInstancerrs r get_source_instancez#MigrationSource.get_source_instance|s"~~11$/BBBr N)/rrrrrr"r[r!r&r*r.rrryr~rxrrrrrrr9rKrErrrrPrSrVrrrrrrrrrrrrhrrrZrr r r r]r]ns ) ) )-,,0002 HZ , ,E;;;h|$$G+++111 /?;;J000::: %H%;=STT""""""#(#8:OPP%%%&&&*,<==J@@@XXXEEESSSZZZ$$$&&& ..X. 68-+-+-+-+`X,<<<333111 kkkCCC+++ CCCCCr r]ceZdZdZdZedZedZedZdZ dZ e dZ e d Z d Zd Zd Zd ZdZdS) MigrationPlanctjjj|_|jsetj|_tjj|j_|jtjj_tj }|dz}tj |r2|jjtj|ntj d}|dz }tj |r1|jjtj|d|_d|_t*jdkr8tj d|_n't*jdkr7tj d|_ntj d|_tj |js[tj tj tjjjjd|_tj |jsd|_d t*jvrtj d|_tj |js[tj tj tjjjjd|_tj |jsd|_n |j|_t=|jt>kr |j|_t=|jt>kr|j|_dSdS) Nz/migration_generic_typemap.xmlr7z+/modules/data/migration_generic_typemap.xmlwin32zwbcopytables.exedarwin wbcopytableszwbcopytables-binlinux) r>rootwbrcrr?db_migration_Migrationr3mformsAppgetget_user_data_folderospathexistsgenericDatatypeMappingsextend unserializeget_resource_pathmigrationSourcemigrationTargetsysplatformget_executable_pathwbcopytables_path_binrdirnameregistryappExecutablePathwbcopytables_pathtypestr)rdatadirr global_paths r rzMigrationPlan.__init__sX[* z \;;==DJ"x{DJ $(JCHK !jnn&&;;==G==Dw~~d## \ 299#/$:O:OPPPP$jnn..@@DD LL 7>>+..\J6==cok>Z>Z[[[## <7 " ")/)9)9)M)MN`)a)aD & & \X % %)/)9)9)M)Mn)])]D & &)/)9)9)M)MN`)a)aD &7>>$"<== G-/W\\"'//#(+J^Jp:q:qtF.G.G*7>>$"<== @-?* cl " "%+Z^^%5%5%I%I.%Y%YD "7>>$"899 )+bgoochkFZFl6m6mo})~)~&7>>$"899 8)7&%)%?D " * + +s 2 2)-)CD & & ' '3 . .%)%;D " " " / .r c&|jr2|j|j|jr|jd|j_dt jj_ d|_d|_d|_dSr) r rrKr rr3r>rrrcrs r closezMigrationPlan.closes   .  ( ( * * *  + + - - -   .  + + - - -  $  ##r cd}d}d}ttjD]}ttj|}t |dr||jkrJ|j}|drt |dr|}|drt |dr|}|drt |dr|}|stj dd|jz|stj dd|jz|stj dd |jz|o|o|S) Nrfrgrhrirj MigrationzGRDBMS %s cannot be a migration source because it's missing a RE module zNRDBMS %s cannot be a migration source because it's missing a Migration module zSRDBMS %s cannot be a migration source because it's missing a Db information module ) rkr>rHrlrmrfrrrn log_debug2)r!rev_eng_modulemigration_module db_modulerorprs r is_rdbms_migratablez!MigrationPlan.is_rdbms_migratables %% E#+u--C3 344 8M8M8O8OSXS]8]8]rr rdbmsMgmtr!rrr|)sourcesr!s r supportedSourceszMigrationPlan.supportedSourcessNX[*0 & &E0077 &u%%%r cDtjjjjdS)Nr)r>rrr!r!r r r supportedTargetszMigrationPlan.supportedTargetssx{$*1--r cd|jr||j_dSt|j||_dSr)r rr]rr4s r setSourceConnectionz!MigrationPlan.setSourceConnections9   K.8D + + +#24:z#J#JD r cft|j||_|jj|j_dSr)r rr r2r3r!r4s r setTargetConnectionz!MigrationPlan.setTargetConnections-.tz:FF%/%6%<"""r c|jjSrr$rs r r%zMigrationPlan.targetCatalog z''r c|jjSrrrrs r rszMigrationPlan.sourceCatalogr+r c|jj|jj|j|jj|j_i}|Sr)r migrationLogr{r rcrir*r rreports r migratezMigrationPlan.migratesQ **,,,'+';'E'T'TUYU_aeaua}'~'~$  r ctjj|jj|jj|jjddi}|S)Nrr) r>rHrIgenerateSQLCreateStatementsr r*rrAobjectCreationParamsr/s r generateSQLzMigrationPlan.generateSQLsU 99$:N:VX\XbXprvr|sR S S S A  r cztjj||jj|jjdSr)r>rHrIcreateScriptForCatalogObjectsr r*rr4)rrs r createTargetScriptz MigrationPlan.createTargetScriptsA ;;D$BVB^`d`j` A A A A Ar c|jjtjj|jj|jj |jj |jjSr) r creationLogr{r>rHrIcreateCatalogObjectsr rr*r4rs r createTargetzMigrationPlan.createTargetsp ))+++{$99$:N:Y[_[o[wy}zDzY[_[e[qrr rr ct|jjdr;|jj|j|jj|j_dStd|jjjzdS)NmigrateUpdateForChangesz>migrateUpdateForChanges method call was skipped for module %s ) rmr rcr>rr r*rrrs r migrationUpdatezMigrationPlan.migrationUpdates 4'13L M M C+/+?+I+a+abfblnroCoK,L,LD ( ( ( WZ^ZnZx[BB C C C C Cr N)rrrrr staticmethodrr#r%r'r)r[r%rsr1r5r8r<r?r r r rrs4,<,<,<\ $ $ $AA\A6\..\.KKK ===((X(((X(AAArrrCCCCCr r) rr r>r workbench.logr Exceptionrobjectr r]rr r r rDs, ######        HHHHHfHHHXOCOCOCOCOCfOCOCOCfYCYCYCYCYCFYCYCYCYCYCr