简体   繁体   中英

Can rake db:create create tables in multiple databases?

Can I create tables in two databases using db:create ? For example, can I have entries in database.yml for one_development and two_development and have both get created by rake db:create ? I know rake db:create:all works -- I am just wondering if there is a way to segment what is created depending on the RAILS_ENV?

For one_development you can execute this command:

RAILS_ENV=one_development rake db:create

For two_development you can execute this command:

RAILS_ENV=two_development rake db:create

Redefine the rake task or create a new one, which runs rake db:create for two environments that you need.

It appears to do all the datasets automatically. See the source:

http://dev.rubyonrails.org/changeset/6849

It does not appear to uses RAILS_ENV like drop, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM