-
Notifications
You must be signed in to change notification settings - Fork 0
Mahaswami/cross-db-migration
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
= Cross DB Migration == Description This plugin allows migrations written once to be run without any changes on MySQL, Oracle and DB2. Though it appears to be not a big deal since the migration syntax is a DSL, in practice Rails migrations written for one RDBMS won't simply work on other databases. This is due to the fact that data base types are named differently in different databases, DDL syntax differences, and number of other subtle differences. == Dependency Cross Db Migration needs ms_base plugin. Kindly make sure the ms_base plugin is loaded prior to this plugin. One way to load the ms_base prior to cross db migration is rename the ms_base folder to 000_ms_base. == How it works When you try to create a table with name more than 30 characters, (which is not allowed in oracle) this plugin will raise an exception even if you use Mysql or DB2 == Supported Actions 1. For create_table DSL a. Table name length check MySql supports 65 character table name, DB2 supports 128 character table name and Oracle supports 30 character table name This plugin will by default restrict us to create table with name length greater than 26 characters, If you are using composite primary key then you can give 30 characters length name by specifying the parameter :skip_table_name_length_check Note: The reason why we are restricting 26 characters length name is if you are using surrogate primary key Oracle will create an index object with name table_name_idx, In oracle the index name also should be less than or equal to 30 characters. b. Adding the camel case table name as table comment for Oracle Database In Oracle dictionary tables the table name will be stored in upper case (even if we specify the table name in camel case), if we want to dump the structure with the table name how we specified in the migration we need to store the table name format some where. This plugin stores the table name as we specified (in the migration) in the comment table and use the table comment to get the formatted table name during schema dump. 2. add_column a. column name length check This plugin restrict us to specify column name with length more than 30 characters. b. Restrict specifying limit for integer datatype This plugin will restrict us to specifying :limit for integer datatype (DB2 will raise an error if we specify :limit for integer datatype) c. Supported addition of NOT NULL column is DB2 In DB2 database, adding a not null column to an existing table (even if the table doesn't have data) is not straight forward. This plugin handled the addition of NOT NULL column for DB2 database (by usine add_column) d. Oracle - recompile the triggers If a table has a trigger and if we add a column the trigger will become unusable, this plugin will take care of recompiling the trigger When ever we add a new column to a table. 3. Rename Table a. In DB2 we cannot rename a table, Hence this plugin will restrict us to rename a table. Note: The work around to rename a table is create a temp table transfer the data to the temp table and drop, recreate the original table and transfer the data back. 4. Rename Column a. rename_column is also restricted in this plugin. 5. Change column This plugin a. restrict us to change the datatype of a column b. restrict us to reduce the limit of string column c. supports to change the NOT NULL column to nullable and vice versa in DB2 database 6. Remove column a. recompile the triggers in Oracle if a column has been removed from a table which has a trigger. 7. Schema dumper: This plugin supports to a. dump oracle functions, triggers and packages b. dump oracle check constraints, unique constraints c. generate sqls for default data d. For oracle DB, picks the table name from the table comment e. Supports composite Primary key tables 8. db_specific_integer_data_type == Issues Post issues via GitHub issues option. == Comments, discussion and feedback. We shall be setting up a google group. In the meantime, please send an email to [email protected] == Author Developed by Mahaswami Software, ([email protected])
About
Write Ruby on Rails active record migrations once and use it across MySQL, Oracle and DB2 seamlessly
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published