Forum: Ruby on Rails run migrations upon boot

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Clemens (Guest)
on 2008-11-13 08:56
(Received via mailing list)
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
Frederick C. (Guest)
on 2008-11-13 12:37
(Received via mailing list)
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
Clemens (Guest)
on 2008-11-13 15:56
(Received via mailing list)
> > 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
Frederick C. (Guest)
on 2008-11-13 16:13
(Received via mailing list)
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
Jeff E. (Guest)
on 2008-11-13 16:56
(Received via mailing list)
>
> Are there better/cleaner alternatives?
>

run at deploy time IMHO

using capistrano, "cap deploy:migrate"
Jeff E. (Guest)
on 2008-11-13 16:58
(Received via mailing list)
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
Clemens (Guest)
on 2008-11-13 19:17
(Received via mailing list)
> 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...) ;-)
Clemens (Guest)
on 2008-11-13 19:19
(Received via mailing list)
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...
Jeff E. (Guest)
on 2008-11-13 22:12
(Received via mailing list)
you could still write a script that copies the war to the servlet
container, restarts it and runs "rake db:migrate RAILS_ENV=whatever"
Clemens (Guest)
on 2008-11-14 09:49
(Received via mailing list)
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?
Jeff E. (Guest)
on 2008-11-14 16:16
(Received via mailing list)
AFAIK the container expands the war to a directory... find that and cd
there
Andy (Guest)
on 2008-11-18 19:59
(Received via mailing list)
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
This topic is locked and can not be replied to.