Changes between Version 18 and Version 19 of GSOC2012/DatabaseMigration/Userguildlines


Ignore:
Timestamp:
08/20/12 17:50:50 (13 years ago)
Author:
anubhav
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GSOC2012/DatabaseMigration/Userguildlines

    v18 v19  
    11[[TOC]]
     2== Comparison Script ==
     3Before using the comparison script , the user of the script should have 2 eden apps , one the containing the old database schema from which the data is to migrated and one with the new database schema
     4
     5The apps_db_comparison script compares the db schema of 2 eden apps to tell the differences
     6Just run the script with 3 necessary arguments in this order
     71.WEB2PY_PATH
     82.OLD_APP
     93.NEW_APP
     10i.e python applications/eden/static/scripts/Database_migration/apps_db_comparison.py /home/web2py eden_old eden_new
     11
     12This script also has an test script that makes 2 new web2py with apps to compare
     13Just run the test script to compare
     14i.e python applications/eden/tests/dbmigration TestScript.py
     15
     16The detected changes are displayed , then using the changes displayed user could figure out the what kind of migration is needed , like if there is a field appeared in the new schema which has the same properties as the one disappeared from the old schema then the migration function for the renaming a field can be called .
     17
     18Also the change in the properties of the fields are detected , the migration function for those can be called too .
     19
    220== Migration Script ==
    321All the functions that does the migration have been added to migration_scripts file . migration_scripts file internally calls the functions of migration_helping_methods file too perform the migration . Thus in order to do the migration one just needs to import migration_scripts and call the method corresponding to the migration he wants . Also the user who wishes to do the migration in the db doesn't have to know the internal functioning of migration_script , thus the functions or the methods declared in migration_helping_methods file doesn't concern him.
     
    4462=== migrating_to_unique_field ===
    4563==== Purpose of the migration====
    46 Adding values to a new field , or update an existing field through the mappings given through the mapping_funation
     64Adding values to a new field and adding values according to the mappings given through the mapping_function
    4765
    4866==== Method of Calling ====
     
    5169import mapping_function
    5270migration_scripts.migrating_to_unique_field( web2py_path, app ,field_to_update , changed_table , list_of_tables)
     71}}}
     72
     73==== Description of arguments ====
     74||= Argument =||= Description =||
     75||web2py_path ||The path to the web2py congaing the Eden app  (i.e "/home/web2py")||
     76||app ||The name of the eden application of whose database needs to be migrated (i.e "eden")||
     77||field_to_update ||The name of the field to be updated according to the mapping||
     78||changed_table ||The name of the original table in which the new unique field id added||
     79||list_of_tables ||These contains the list of tables which the changed_tables references||
     80
     81
     82=== update_field_by_mapping ===
     83==== Purpose of the migration====
     84 Update the the values of an existing field according to the mappings given through the mapping_function
     85
     86==== Method of Calling ====
     87{{{#!python
     88import migration_scripts
     89import mapping_function
     90migration_scripts.update_field_by_mapping( web2py_path, app ,field_to_update , changed_table ,mapping_function, list_of_tables)
    5391}}}
    5492
     
    86124||old_table ||The name of the original table||
    87125
     126== Tests for Migration ==
     127The links for all of the migrations
     128=== Migration script ===
     129    https://github.com/anubhav929/Dbmigration-final-/blob/master/tests/dbmigration/test_migrations.py
     130This script when run shows a menu with all the tests options , choose the migration that you want to test
     131
    88132== Links for the scrips ==
    89133I have made it the database migration in the form of the library ,