run migrations upon boot

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

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

> 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

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"?

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

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

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:

as mentioned above, deploying the app as a "war" into GlassFish, hence
no capistrano...

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?

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

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