Warbler migrations

What strategies are folks using to migrate databases for Warbler based
applications?

I’ve found this troublesome in the past because I typically want to run
“rake db:migrate” from my production server, but with Warbler I don’t
necessarily have everything I need (i.e. db/, Rakefile, etc).

I’ve been playing around with the idea of making my WAR file such that I
could run:

java -jar myapp.war -S rake db:migrate

But I forgot how annoying jar inside of jars can be.

Does anyone have suggestions on the best way to approach this? Does
executing the WAR with rake tasks sound worth the effort?

-joe

Hi Joe,

On Wed, Oct 26, 2011 at 9:52 AM, Joe K. [email protected] wrote:

What strategies are folks using to migrate databases for Warbler based
applications?

I’ve found this troublesome in the past because I typically want to run “rake
db:migrate” from my production server, but with Warbler I don’t necessarily have
everything I need (i.e. db/, Rakefile, etc).

The two common strategies I hear about are a) running migrations at
war deployment time with a separate servlet context listener (like
1), and b) unpacking the war contents and including a script to run
rake on the unpacked war. Both require packing your db/migrations
directory inside, obviously.

I’ve been playing around with the idea of making my WAR file such that I could
run:

java -jar myapp.war -S rake db:migrate

But I forgot how annoying jar inside of jars can be.

We’ve wanted to do this for a while too. There’s this ticket (and the
start of some code):

Does anyone have suggestions on the best way to approach this? Does executing
the WAR with rake tasks sound worth the effort?

Definitely. If you feel like helping out, please do!

/Nick

Thanks Nick. That’s helpful.

I’ve got the WAR CLI thing working to the point that I can run things
like:

$ java -jar myapp.war -S gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.5.1
  • RUBY VERSION: 1.9.2 (2011-08-23 patchlevel 136) [java]
  • INSTALLATION DIRECTORY:
    file:/tmp/jruby-stdlib2489559150484946376.jar!/META-INF/jruby.home/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: java -jar /tmp/jruby-stdlib2489559150484946376.jar
  • EXECUTABLE DIRECTORY:
    file:/tmp/jruby-stdlib2489559150484946376.jar!/META-INF/jruby.home/bin

And I can run rake if use the -f option (i want it to pick up the
Rakefile I put in my WAR file).

You can see what I’m doing here:

I’m still working on getting the WEB-INF/gems dir on the GEM_PATH. And
I have a few other kinks to work out. But I’ll submit a pull request
eventually. Let me know if you have any tips.

Thanks,

-Joe