In my environment, the application logins do not have the ability to alter the schema to create tables, etc. There is a separate schema owner account with that capability. So I cannot run "rake migrate" using the database.yml configuration. Is there a way to run migrations with a different account? Thanks, - Mark. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Sep 04, 2007 at 07:19:10PM -0000, Mark Thomas wrote:> In my environment, the application logins do not have the ability to > alter the schema to create tables, etc. There is a separate schema > owner account with that capability. So I cannot run "rake migrate" > using the database.yml configuration. Is there a way to run migrations > with a different account?There isn''t any magical way to do more than the permissions you have allow you to do, if that''s what you''re asking. If you have a different db user account that has sufficient permissions, then just plug it into the database.yml file. -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Let me be more specific. My rails app is not allowed to use the schema owner account, so I cannot just put it in the database.yml file. In addition, I cannot leave the password for that account on the filesystem. So even if there was a way to select a different database.yml file for the migrations only, I cannot do that. (Although I''d still be interested to know if there''s a way to select a different database.yml on the fly). What would be ideal: a front end to rake db:migrate that asks me for the username/password to the account, and overrides the database.yml entries for them. Is there a way to do this via a new rake task? Or maybe it would be easier to modify the existing db:migrate task? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Thomas wrote:> Let me be more specific. My rails app is not allowed to use the schema > owner account, so I cannot just put it in the database.yml file. In > addition, I cannot leave the password for that account on the > filesystem. So even if there was a way to select a different > database.yml file for the migrations only, I cannot do that. (Although > I''d still be interested to know if there''s a way to select a different > database.yml on the fly). > > What would be ideal: a front end to rake db:migrate that asks me for > the username/password to the account, and overrides the database.yml > entries for them. Is there a way to do this via a new rake task? Or > maybe it would be easier to modify the existing db:migrate task?how about this solution; database.yml =========== <% def as_db_admin? defined?(AS_DB_ADMIN) && AS_DB_ADMIN == "true" end %> production: adapter: mysql database: databasename host: localhost username: <%= as_db_admin? ? "root" : "normal" %> password: <%= as_db_admin? ? "root" : "normal" %> =========== "rake db:migrate AS_DB_ADMIN=true" I belive that''ll set the global constant AS_DB_ADMIN, and hence do what you want. Otherwise it sets ENV["AS_DB_ADMIN"] but I think it actually sets the constant directly. Give it a try. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Huh? YAML files are run through ERB? I wouldn''t have thought this to be the case. Nevertheless, I''ll try it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Thomas wrote:> Huh? YAML files are run through ERB? I wouldn''t have thought this to > be the case. Nevertheless, I''ll try it.yeah. it''s not obvious, until you look at the code. I use it all the time, so I can do host specific databases (namely I have 3 different environments I want to run the tests on, some of them have the database running on localhost, but the others have dedicated db servers with different names) it works proper fine. <% def sharon_or_localhost if ["punky", "munky"].include? Socket.gethostname return "sharon" else return "localhost" end end %> test: adapter: mysql database: testdb username: test_user password: th1si5aTESt host: <%= sharon_or_localhost %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
and here''s the code out of the rails initializer # Loads and returns the contents of the #database_configuration_file. The # contents of the file are processed via ERB before being sent through # YAML::load. def database_configuration YAML::load(ERB.new(IO.read(database_configuration_file)).result) end see railties/lib/initializer.rb -- don''t know which line. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sep 5, 9:43 am, Mark Thomas <r...-gkTqyYPWbQbz1n+OaKNE4w@public.gmane.org> wrote:> Huh? YAML files are run through ERB? I wouldn''t have thought this to > be the case. Nevertheless, I''ll try it.Nope, it is as I thought--you can''t put ERB into database.yml. I''m going down the path of trying a custom rake task, but I have no idea where database.yml exists as a variable after it has been loaded by Rails. Does anyone know? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Thomas wrote:> On Sep 5, 9:43 am, Mark Thomas <r...-gkTqyYPWbQbz1n+OaKNE4w@public.gmane.org> wrote: >> Huh? YAML files are run through ERB? I wouldn''t have thought this to >> be the case. Nevertheless, I''ll try it. > > Nope, it is as I thought--you can''t put ERB into database.yml.hmm... well I haven''t bothered to go any further back than revision 2115, but ERB parsing of database.yml has been in rails trunk since at least September 2005, maybe before then even. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 Rudy wrote:> Mark Thomas wrote: >> On Sep 5, 9:43 am, Mark Thomas <r...-gkTqyYPWbQbz1n+OaKNE4w@public.gmane.org> wrote: >>> Huh? YAML files are run through ERB? I wouldn''t have thought this to >>> be the case. Nevertheless, I''ll try it. >> >> Nope, it is as I thought--you can''t put ERB into database.yml.and equally; ActiveRecord::Base.configurations is the hash of the database connections. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 Rudy wrote:> Matthew Rudy wrote: >> Mark Thomas wrote: >>> On Sep 5, 9:43 am, Mark Thomas <r...-gkTqyYPWbQbz1n+OaKNE4w@public.gmane.org> wrote: >>>> Huh? YAML files are run through ERB? I wouldn''t have thought this to >>>> be the case. Nevertheless, I''ll try it. >>> >>> Nope, it is as I thought--you can''t put ERB into database.yml. > > and equally; > ActiveRecord::Base.configurations is the hash of the database > connections.and I think this rake task will do what you want also ===============/lib/tasks/migrate_as_root.rake =============== ROOT_USER_PASS_HASH = {"username" => "root", "password" => "rootpass"} desc "run your migration as db root" task "db:migrate_as_root" do original_config = ActiveRecord::Base.configurations[RAILS_ENV || "development"] config = original_config.merge(ROOT_USER_PASS_HASH) ActiveRecord::Base.establish_connection(config) Rake::Task["db:migrate"].invoke end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> well I haven''t bothered to go any further back than revision 2115, > but ERB parsing of database.yml has been in rails trunk since at least > September 2005, maybe before then even.Well then I apologize. My quick test didn''t work and I guess I jumped to the conclusion.> > and equally; > > ActiveRecord::Base.configurations is the hash of the database > > connections.Thanks!> and I think this rake task will do what you want also > > ===============> /lib/tasks/migrate_as_root.rake > ===============> > ROOT_USER_PASS_HASH = {"username" => "root", "password" => "rootpass"} > > desc "run your migration as db root" > task "db:migrate_as_root" do > original_config = ActiveRecord::Base.configurations[RAILS_ENV || > "development"] > config = original_config.merge(ROOT_USER_PASS_HASH) > ActiveRecord::Base.establish_connection(config) > > Rake::Task["db:migrate"].invoke > endYes! This is very close to what I need. I''ll take it from here. Thank you very much! - Mark. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Thomas wrote:> > > Yes! This is very close to what I need. I''ll take it from here. Thank > you very much! > > - Mark.Yeah, no wuzz... I don''t like being wrong. Take it easy.... btw, do you happen to know of Mark Thomas the english comedian/activist... he''s pretty darn cool. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Thomas wrote in post #550700:>> well I haven''t bothered to go any further back than revision 2115, >> but ERB parsing of database.yml has been in rails trunk since at least >> September 2005, maybe before then even. > > Well then I apologize. My quick test didn''t work and I guess I jumped > to the conclusion. > >> > and equally; >> > ActiveRecord::Base.configurations is the hash of the database >> > connections. > > Thanks! > >> original_config = ActiveRecord::Base.configurations[RAILS_ENV || >> "development"] >> config = original_config.merge(ROOT_USER_PASS_HASH) >> ActiveRecord::Base.establish_connection(config) >> >> Rake::Task["db:migrate"].invoke >> end > > Yes! This is very close to what I need. I''ll take it from here. Thank > you very much! > > - Mark.Were you able to do this successfully? And how did you handle capistrano tasks? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f876ab60842cd05af53fdfc3325ed6ee%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.