Run migrations upon boot


#1

We are in the development phase of a rails app which is hosted as war
in GlassFish. Deployment works well, except for the migration part
(which requires manual interaction).

My question:
is it “acceptable” to run migrations upon boot OR by invoking them
from within an admin page?

Are there better/cleaner alternatives?

Thx
Clemens


#2

On Nov 13, 6:55 am, Clemens removed_email_address@domain.invalid wrote:

We are in the development phase of a rails app which is hosted as war
in GlassFish. Deployment works well, except for the migration part
(which requires manual interaction).

My question:
is it “acceptable” to run migrations upon boot OR by invoking them
from within an admin page?

If you ran them from the admin page then at the very least you would
need to call reset_column_information on all your model classes (in
all instances of your application)

Fred


#3

My question:
is it “acceptable” to run migrations upon boot OR by invoking them
from within an admin page?

If you ran them from the admin page then at the very least you would
need to call reset_column_information on all your model classes (in
all instances of your application)

Fred
Dear Fred,
does this also apply to calling migrations upon boot, or woud that be
“safe”?

if (ActiveRecord::Migrator.new(:up, ‘db/
migrate’).pending_migrations.length > 0)
ActiveRecord::Migration.verbose = false
ActiveRecord::Migrator.migrate(“db/migrate/”, nil)
end

Thx
Clemens


#4

Are there better/cleaner alternatives?

run at deploy time IMHO

using capistrano, “cap deploy:migrate”


#5

On Nov 13, 9:55 am, jemminger removed_email_address@domain.invalid wrote:

Are there better/cleaner alternatives?

run at deploy time IMHO

using capistrano, “cap deploy:migrate”

and to avoid having to issue more than one cap command for a deploy
and migrate, I typically define a task to do it all:

namespace :deploy do
task :long do
web.disable
default
migrate
web.enable
end
end


#6

On 13 Nov 2008, at 13:55, Clemens wrote:

Dear Fred,
does this also apply to calling migrations upon boot, or woud that be
“safe”?

Depends what you mean by on boot. Would each instance of the app try
and run the migrations ? That would probably result in bad stuff.

Fred


#7

Depends what you mean by on boot. Would each instance of the app try
and run the migrations ? That would probably result in bad stuff.
didn’t htink about this (mongrel cluster…) :wink:


#8

you could still write a script that copies the war to the servlet
container, restarts it and runs “rake db:migrate RAILS_ENV=whatever”


#9

On 13 Nov., 15:55, jemminger removed_email_address@domain.invalid wrote:

Are there better/cleaner alternatives?

run at deploy time IMHO

using capistrano, “cap deploy:migrate”

as mentioned above, deploying the app as a “war” into GlassFish, hence
no capistrano…


#10

On 13 Nov., 21:11, jemminger removed_email_address@domain.invalid wrote:

you could still write a script that copies the war to the servlet
container, restarts it and runs “rake db:migrate RAILS_ENV=whatever”
but all the rails sources are IN the war…? Where should I run rake?


#11

AFAIK the container expands the war to a directory… find that and cd
there


#12

Dear Clemens,

I tried similar thing, but doesn’t go well because web server doesn’t
run without DB tables.
How did you handle this issue?

Andy