wiki:GSOC2012/DatabaseMigration/Userguildlines

Version 9 (modified by anubhav, 12 years ago) ( diff )

--

Comparson script

Migration Script

All 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.

Methods in migration_scripts file

migrating_to_unique_field

Purpose of the migration

Method of Calling

import migration_scripts
import mapping_function
migration_scripts.migrating_to_unique_field( web2py_path, app ,field_to_update , changed_table , list_of_tables, mapping_function)

Description of arguments

Argument Description
web2py_path The path to the web2py congaing the Eden app (i.e "/home/web2py")
app The name of the eden application of whose database needs to be migrated (i.e "eden")
field_to_update The name of the field with the unique and notnull property
changed_table The name of the original table in which the new unique field id added
list_of_tables These contains the list of tables which the changed_tables references
mapping_function Gives the mappings to load the new values in the unique field

migration_renaming_field

Purpose of the migration

Method of Calling

import migration_scripts
migration_scripts.migration_renaming_field(web2py_path, app, old_table, old_field_name , new_field_name ,attributes_to_copy)

Description of arguments

Argument Description
web2py_path The path to the web2py congaing the Eden app (i.e "/home/web2py")
app The name of the eden application of whose database needs to be migrated (i.e "eden")
old_table The name of the table in which the field is renamed
old_field_name The name of the original field before renaming
new_field_name The name of the field after renaming
attributes_to_copy The list of attributes which needs to be copied from the old_field to the new_field (needed only in sqlite)

migration_renaming_table

Purpose of the migration

Method of Calling

import migration_scripts
migration_scripts.migration_renaming_table(web2py_path, app ,old_table_name,new_table_name)

Description of arguments

Argument Description
web2py_path The path to the web2py congaing the Eden app (i.e "/home/web2py")
app The name of the eden application of whose database needs to be migrated (i.e "eden")
old_table_name The name of the original table before renaming
new_table_name The name of the table after renaming

list_field_to_reference

Purpose of the migration

Example of the migration

http://pastebin.ubuntu.com/1142568/

Method of Calling

import migration_scripts
migration_scripts.list_field_to_reference(web2py_path,app,new_table_name , new_list_field , list_field_name , old_table_id_field , old_table)

Description of arguments

Argument Description
web2py_path The path to the web2py congaing the Eden app (i.e "/home/web2py")
app The name of the eden application of whose database needs to be migrated (i.e "eden")
new_table_name The name of the new table to which the list field needs to migrated
new_list_field The name of the field in the new table which will hold the content of the list field
list_field_name The name of the list field in the original table
old_table_id_field The name of the id field in the original table
old_table The name of the original table
Note: See TracWiki for help on using the wiki.