Changes between Version 9 and Version 10 of GSOC2012/DatabaseMigration/Userguildlines
- Timestamp:
- 08/16/12 15:56:16 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GSOC2012/DatabaseMigration/Userguildlines
v9 v10 13 13 import migration_scripts 14 14 import mapping_function 15 migration_scripts.migrating_to_unique_field( web2py_path, app ,field_to_update , changed_table , list_of_tables , mapping_function)15 migration_scripts.migrating_to_unique_field( web2py_path, app ,field_to_update , changed_table , list_of_tables) 16 16 }}} 17 17 … … 22 22 ||field_to_update ||The name of the field with the unique and notnull property|| 23 23 ||changed_table ||The name of the original table in which the new unique field id added|| 24 ||list_of_tables || These contains the list of tables which the changed_tables references || 25 ||mapping_function || Gives the mappings to load the new values in the unique field || 24 ||list_of_tables ||These contains the list of tables which the changed_tables references|| 26 25 27 26 === migration_renaming_field === 28 27 ==== Purpose of the migration==== 28 Renaming a particular table , Thus if any fields point to that table that should be handled too. 29 29 30 30 ==== Method of Calling ==== … … 46 46 === migration_renaming_table === 47 47 ==== Purpose of the migration==== 48 Renaming a particular field , while keeping the other properties of the field same. Also if there are some index on that table that should be recreated and other constraints should remain unchanged too. 48 49 49 50 ==== Method of Calling ==== … … 63 64 === list_field_to_reference === 64 65 ==== Purpose of the migration==== 66 Some fields that have types like list:integer or list:reference or list:string. These types encode multiple values into one string field. What's in the field looks something like this: "|5|100|23|" -- it has values separated by vertical bars. This is an official Web2py type, and typically Web2py handles packing and unpacking these fields: 67 68 Sometimes people find they need to pull those values out into a separate resource. There are various reasons they might want to do this, e.g. they might find they need more than one item of information, so instead of a single value, which might be easy to pack into a list, they want instead to have a separate table in which they can have multiple columns, and join that to the original table. To start with, they make a new table with a column for the values they'll get from the list field, and maybe some empty columns to be filled in later. That new table has a foreign key reference back to the original table. Then for each value in the list field for each record in the original table, they create one record in the new table that points back to the original record. 65 69 66 70 ==== Example of the migration ====