Search code examples
ruby-on-railsruby-on-rails-4activerecordrake

Where does the structure from rake db:structure:dump come from?


I want to know where rake db:structure:dump gets it's structure from!

Development? Staging? Production? I assume development is the standard!

Can I specify the environment where it comes from?


Solution

  • As with every single database-centric command in Rails, it talks to the database defined by your current environment, defaulting to Development.

    You can specify the environment for any and every Rails command by setting the environment variable RAILS_ENV.

    To dump your database schema for development:

    $ RAILS_ENV=development rake db:schema:dump
    

    To dump your database schema for production:

    $ RAILS_ENV=production rake db:schema:dump