Matthew Flint
2007-Nov-28 11:43 UTC
No shell access - how to run migrations on production db?
Hey, I have no shell access to the production server, but would still like to use migrations to maintain the database. Is it possible to run migrations from Ruby code itself (ie, without using ''rake'')? If so, I''ll be able to run migrations by hitting a ''migration'' controller, with the URL specifying the version number somehow. (Yes, I appreciate the potential problems with having a publicly-accessible migration URL) Thanks in advance for any ideas... Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
toby privett
2007-Nov-28 11:57 UTC
Re: No shell access - how to run migrations on production db?
> I have no shell access to the production server, but would still like > to use migrations to maintain the database.How are you currently deploying the application? If using Capistrano, it''s as simple as: cap deploy:migrate --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Flint
2007-Nov-28 12:05 UTC
Re: No shell access - how to run migrations on production db?
Nov 28, 11:57 am, "toby privett" <tobypriv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have no shell access to the production server, but would still like > > to use migrations to maintain the database. > > How are you currently deploying the application?ftp. (It''s highly technical! ;-) M --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
toby privett
2007-Nov-28 12:14 UTC
Re: No shell access - how to run migrations on production db?
> ftp. (It''s highly technical! ;-)Ouch. I haven''t had that problem since my asp days in the 90s. From the AWD... book: "All of the migration methods described so far in this chapter are also available as methods on Active Record connection objects and so are accessible within the models, views, and controllers of a Rails application. " So you could have a controller (with restricted access!) to accept an http request that calls a model / method to run the migration. You could even pass a version number as a parameter. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Flint
2007-Nov-28 13:57 UTC
Re: No shell access - how to run migrations on production db?
On Nov 28, 12:14 pm, "toby privett" <tobypriv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > ftp. (It''s highly technical! ;-) > > Ouch. I haven''t had that problem since my asp days in the 90s. > > From the AWD... book: > > "All of the migration methods described so far in this chapter are > also available > as methods on Active Record connection objects and so are accessible within > the models, views, and controllers of a Rails application. " > > So you could have a controller (with restricted access!) to accept an > http request that calls a model / method to run the migration. > > You could even pass a version number as a parameter.That sounds like a plan - thanks for you ideas Toby. M --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Nov-28 14:37 UTC
Re: No shell access - how to run migrations on production db?
On Nov 28, 2007 6:43 AM, Matthew Flint <mkflint-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hey, > > I have no shell access to the production server, but would still like > to use migrations to maintain the database. > > Is it possible to run migrations from Ruby code itself (ie, without > using ''rake'')?Yes, if you look at vendor/rails/railties/lib/tasks/databases.rake, you''ll see what rake db:migrate does. It''s just one line: ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) If you always want to migrate up to latest version, just use: ActiveRecord::Migrator.migrate("db/migrate/") ActiveRecord::Migrator is undocumented (there''s too much undocumented stuff in Rails; I use http://caboo.se/doc/ to hunt for this kind of thing). The rake task also dumps the schema, but you wouldn''t need to worry about that. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Flint
2007-Nov-28 14:44 UTC
Re: No shell access - how to run migrations on production db?
On Nov 28, 2:37 pm, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 28, 2007 6:43 AM, Matthew Flint <mkfl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey, > > > I have no shell access to the production server, but would still like > > to use migrations to maintain the database. > > > Is it possible to run migrations from Ruby code itself (ie, without > > using ''rake'')? > > Yes, if you look at vendor/rails/railties/lib/tasks/databases.rake, > you''ll see what rake db:migrate does. It''s just one line: > > ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? > ENV["VERSION"].to_i : nil) > > If you always want to migrate up to latest version, just use: > > ActiveRecord::Migrator.migrate("db/migrate/") > > ActiveRecord::Migrator is undocumented (there''s too much undocumented > stuff in Rails; I usehttp://caboo.se/doc/to hunt for this kind of > thing). > > The rake task also dumps the schema, but you wouldn''t need to worry about that.Thank-you Bob - that''s exactly what I was looking for :-) Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Flint
2007-Dec-04 09:07 UTC
Re: No shell access - how to run migrations on production db?
For anyone with the same problem, I blogged a quick-and-dirty solution here: http://insignificant.org/2007/12/03/rails-migration-without-ssh/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---