Politics, Programming and Possibilities
3 Mar
Kyle Maxwell tipped me off to the lunchbox blog where Scott Barron wrote about an “auto-fill reverse migration” command for TextMate.
Unfortunately, Scott lost his work in a hard drive crash a while back, so I wasn’t able to use his work. But I did steal his idea! In the latest syncPEOPLE on Rails bundle (now in the TextMate Bundle repository) you can use the “Migration Drop and Create Table” macro/snippet combination.
Basically, what happens is since it knows you’re trying to drop a table, it uses your schema.rb file to figure out how to re-create the table for your migration’s self.down method. All in one context-sensitive snippet triggered by “mdct[tab]“.
2 Responses for "Auto-fill Reverse Migration"
Hm, for some reasons it doesn’t work for me:
/Users/kent/Library/Application Support/TextMate/Bundles/Rails.tmbundle/Support/lib/rails/buffer.rb:90:in `find’: private method `scan’ called for nil:NilClass (NoMethodError)
from /Users/kent/Library/Application Support/TextMate/Bundles/Rails.tmbundle/Support/lib/rails/buffer.rb:88:in `find’
from /Users/kent/Library/Application Support/TextMate/Bundles/Rails.tmbundle/Support/bin/insert_create_table.rb:24
Should be resolved now. If the current file was larger than the schema.rb file, there was a “buffer overrun” going on (protected, of course, by Ruby, so nothing serious).
Leave a reply