README

Path: vendor/plugins/migration_assist/README
Last Update: Tue Sep 18 13:30:42 -0500 2007

migration_assist version 1.0

This plug-in provides rake tasks to assist with the management of migration files. The rake tasks do not modify, copy, rename, or move actual migration files. Only the commands needed to accomplish the task are printed and can be cut and pasted into a terminal. The tasks take into account whether or not Subversion is being used to manage migration source code.

Currently only Unix and Mac OS X commands are supported, due to the fact that I do not have a MS Windows computer available for testing. Patches to fix the lack of Windows support are welcome and should be emailed to:

 kelly@whoisat@drotner.com

Resources

To install

 piston import http://svn.drotner.org/repos/rails/plugins/migration_assist/trunk/migration_assist vendor/plugins/migration_assist

 ./script/plugin install http://svn.drotner.org/repos/rails/plugins/migration_assist/trunk/migration_assist

Usage

rake migration:list

Simply lists out the filenames of all migrations.

Example:

 $ rake migration:list
 (in /Volumes/usr1/temp/mig)
 001_create_users.rb
 002_create_people.rb
 003_create_foos.rb
 004_create_bars.rb
 005_create_bazs.rb
 006_create_emails.rb
 007_create_phones.rb
 008_create_instant_messengers.rb
 009_create_phone_types.rb
 010_create_instant_messenger_types.rb
 011_create_jobs.rb
 012_create_job_types.rb

Nothing exciting…

rake migration:renumber FROM=number TO=number

This rake task will print out the commands needed to renumber the migration starting with the FROM=number to the TO=number as well as renumbering any other migrations needed to make TO=number fit.

Examples:

 $ rake migration:renumber FROM=3 TO=6
 (in /Volumes/usr1/temp/mig)
 Cut and paste the following...
 ----- BEGIN -----

 rake db:migrate VERSION=002
 cd db/migrate
 mv 004_create_bars.rb 003_create_bars.rb
 mv 005_create_bazs.rb 004_create_bazs.rb
 mv 006_create_emails.rb 005_create_emails.rb
 mv 003_create_foos.rb 006_create_foos.rb
 cd ../..
 rake db:migrate

 ----- END -----

 $ # Do the cut-n-paste

 $ rake migration:list
 (in /Volumes/usr1/temp/mig)
 001_create_users.rb
 002_create_people.rb
 003_create_bars.rb
 004_create_bazs.rb
 005_create_emails.rb
 006_create_foos.rb
 007_create_phones.rb
 008_create_instant_messengers.rb
 009_create_phone_types.rb
 010_create_instant_messenger_types.rb
 011_create_jobs.rb
 012_create_job_types.rb

 $ rake migration:renumber FROM=5 TO=10
 (in /Volumes/usr1/temp/mig)
 Cut and paste the following...
 ----- BEGIN -----

 rake db:migrate VERSION=004
 cd db/migrate
 mv 006_create_foos.rb 005_create_foos.rb
 mv 007_create_phones.rb 006_create_phones.rb
 mv 008_create_instant_messengers.rb 007_create_instant_messengers.rb
 mv 009_create_phone_types.rb 008_create_phone_types.rb
 mv 010_create_instant_messenger_types.rb 009_create_instant_messenger_types.rb
 mv 005_create_emails.rb 010_create_emails.rb
 cd ../..
 rake db:migrate

 ----- END -----

 $ # Do the cut-n-paste

 $ rake migration:list
 (in /Volumes/usr1/temp/mig)
 001_create_users.rb
 002_create_people.rb
 003_create_bars.rb
 004_create_bazs.rb
 005_create_foos.rb
 006_create_phones.rb
 007_create_instant_messengers.rb
 008_create_phone_types.rb
 009_create_instant_messenger_types.rb
 010_create_emails.rb
 011_create_jobs.rb
 012_create_job_types.rb

Be sure to not just blindly copy and paste the commands. Look to make sure that the suggested commands make sense.

rake migration:close_gaps

This rake task will print out the commands needed to close up any migration numbering gaps.

Example:

 $ rake migration:list
 (in /Volumes/usr1/temp/mig)
 001_create_users.rb
 002_create_people.rb
 006_create_phones.rb
 007_create_instant_messengers.rb
 008_create_phone_types.rb
 009_create_instant_messenger_types.rb
 010_create_emails.rb
 011_create_jobs.rb
 012_create_job_types.rb
 013_create_bars.rb
 014_create_bazs.rb
 015_create_foos.rb

 $ rake migration:close_gaps
 (in /Volumes/usr1/temp/mig)
 Cut and paste the following...
 ----- BEGIN -----

 rake db:migrate VERSION=002
 cd db/migrate
 mv 006_create_phones.rb 003_create_phones.rb
 mv 007_create_instant_messengers.rb 004_create_instant_messengers.rb
 mv 008_create_phone_types.rb 005_create_phone_types.rb
 mv 009_create_instant_messenger_types.rb 006_create_instant_messenger_types.rb
 mv 010_create_emails.rb 007_create_emails.rb
 mv 011_create_jobs.rb 008_create_jobs.rb
 mv 012_create_job_types.rb 009_create_job_types.rb
 mv 013_create_bars.rb 010_create_bars.rb
 mv 014_create_bazs.rb 011_create_bazs.rb
 mv 015_create_foos.rb 012_create_foos.rb
 cd ../..
 rake db:migrate

 ----- END -----

 $ # Do the cut-n-paste

 $ rake migration:list
 (in /Volumes/usr1/temp/mig)
 001_create_users.rb
 002_create_people.rb
 003_create_phones.rb
 004_create_instant_messengers.rb
 005_create_phone_types.rb
 006_create_instant_messenger_types.rb
 007_create_emails.rb
 008_create_jobs.rb
 009_create_job_types.rb
 010_create_bars.rb
 011_create_bazs.rb
 012_create_foos.rb

Again, be sure to not just blindly copy and paste the commands. Look to make sure that the suggested commands make sense.

Author

  • Kelly McCauley - kelly@whoisat@drotner.com - drotner.org

Problems, comments, and suggestions are much welcomed.

Copyright

Copyright (c) 2007 Kelly McCauley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[Validate]