views:

32

answers:

1

If no need to migrate the data, it seems that we can just edit database.yml

development:
  adapter: mysql
  database: myapp_development
  host: localhost
  username: root
  password:
  encoding: utf8

1) to use a brand new db with 0 data, just change the 3rd line to:

database: myapp_development_02

and then do a rake db:create and rake db:migrate and now, we have a brand new db with zero data?

2) if it was specifying using SQLite, we can just change it to the MySQL description as the top part of this post, and also do a rake db:create and rake db:migrate, and now we have a brand new db to work with, and is MySQL?

3) Rails 3 has a db/schema.rb. Can this be used instead of rake db:migrate, which will involve 30 migrations if there are 30 migration files, but if using schema.rb, then it can reach the database schemas in one step?

4) I think we can create other development_02, etc, in the database.yml file, pointing to the old db, or pointing to different DBMS, but just make sure we run with

rails ... -e development_02 ...
  or 
rake ... RAILS_ENV=development_02

?

A: 
  1. Yes
  2. Yes
  3. Yes. In fact, this is the preferred way if you have a big schema.
  4. Yes. But you'll need to add config/environments/development_02.rb
Faisal
Disclaimer regarding point 4: this is Rails 2.x style. I do not know if changed in Rails 3.0, but I don't think it changed.
Faisal