Bashfully yours, Migrations w/o Migraines
, Chicago
Let’s face it. The migration timestamps, nice for teams and conflicts, are a bit painful otherwise. You create a migration and want to open it quickly, but the tab-completion is awkward. Too many numbers (shared by too many files) gum up the whole process.
$ script/generate migration add_comments_count_to_blog_entry comments_count:integer
create db/migrate
create db/migrate/20080807210534_add_comments_count_to_blog_entry.rb
$ mate db→/m→igrate/2→0080→→
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
20080[...]
[...]
--More--
$ mate db/migrate/20080
And that’s just the beginning. Copypasta? Sure…but do I really have to take my fingers from the keyboard?
How about a better way, with ~/.bash_profile:
Let’s try it out.
source ~/.bash_profile
sgmi add_comments_count_to_blog_entry comments_count:integer
A quick edit, save, close, and…
(in ~/Code/blog/trunk)
== 20080807210534 AddCommentsCountToBlogEntry: migrating ======================
-- add_column(:blog_entries, :comments_count, :integer, {:default=>0})
-> 0.0360s
== 20080807210534 AddCommentsCountToBlogEntry: migrated (0.0360s) =============
Beautiful. Migration editing without migraines.