Sometimes you want to run a Rails migration in only one environment. Say for the sake of argument you have a messy legacy app and you need to add database sessions immediately, without going into the cleanup you have to do on the development environment side.
There's probably a more elegant way to do this, but this is the quick and dirty shortcut.
(Got the idea from the Rails wiki.)
Friday, July 6, 2007
Subscribe to:
Post Comments (Atom)













Would
ReplyDeleterake db:migrate RAILS_ENV=production
be sufficient? That appears to be the end result of your script.
hahahahaha
ReplyDeletedoh.
yes. that would probably work.
and VERSION= if you need to specify that too. ;)
ReplyDeleteJust a thing here - my initial response seems kind of painfully inane to me. So, yes, Matt's solution is the right way to do it. This is just how you do it in a hurry. If you're working with Mongrel, migrations, and the console, you've got to remember that one takes -e production, another RAILS_ENV=production, and another simply the quoted string 'production'. The whole point of working with shell aliases and the console is speed and productivity.
ReplyDeleteI couldn't remember which of those command-line options was which. Ironically, for this particular case, posting the wrong thing in your blog actually turns out to be a more efficient way of finding the answer than looking it up via Google.