I just started in to migrations and thought "Wouldn''t it be nice
if I
could, on the first migration, call ''create_database'' and then
go
ahead and create all of the tables?"
Unfortunately, it seems that an ActiveRecord assumption is that a
valid database exists before it will connect:
irb(main):006:0> c = ActiveRecord::Base.configurations
=> {"development"=>{"username"=>"root",
"adapter"=>"mysql",
"host"=>"localhost", "password"=>nil,
"database"=>"premier_adoptions_dev"},
"production"=>
{"username"=>"root",
"adapter"=>"mysql",
"host"=>"localhost",
"password"=>nil,
"database"=>"rails_production"}, "test"=>
{"username"=>"root",
"adapter"=>"mysql",
"host"=>"localhost",
"password"=>nil,
"database"=>"premier_adoptions_test"}}
irb(main):007:0> c["development"].delete "database"
irb(main):013:0> ActiveRecord::Base.connection
ArgumentError: No database specified. Missing argument: database.
from ./vendor/rails/activerecord/lib/active_record/
connection_adapters/mysql_adapter.rb:34:in `mysql_connection''
Under all circumstances but this one, I think that''s a good idea--so
I wonder, is there a way to connect to MySQL (or pgsql or whatever
the db may be) for the purpose of creating a database?
I have a project that may require the dynamic creation of an entire
database for each client, so even if this is not possible for
migrations, I will have to find another way soon.
Thank-you,
Duane Johnson
(canadaduane)
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails