Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

The rake tasks db:create and db:drop throws an error when the database.yml file is configured in a non default location.

#4141

The rake tasks db:create and db:drop throws an error when the database.yml file is configured in a non default location.

The database.yml file location is configured using the database_configuration_file attribute of Rails::Configuration class.

environment.rb

RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
  config.time_zone = 'UTC'

  # configure the database.yml file location
  config.database_configuration_file = File.join("c:/siteconfig/test", 'database.yml')
end

Rake tasks db:drop and db:create throw the following error:

>rake db:drop
(in C:/test)
rake aborted!
No such file or directory - C:/test/config/database.yml
I am able to run the other rake tasks such as db:migrate. The rails application runs without any error.

I located the issue in db:load_config.

task :load_config => :rails_env do
 require 'active_record'
 ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
end
This task ignores the database config file location override in environment.rb. Hence the location always defaults to RAILS_ROOT/config/database.yml.

Reported by Kandada Boggu · March 10th, 2010 @ 09:11 AM

State: open
Milestone: 2.3.10
Assigned to: nobody
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from databases.rake, rake_dev to databasesrake, rake_dev

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:54 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:54 PM

  3. Kandada Boggu
    Kandada Boggu
    • Assigned user set to Santiago Pastorino

    I can still reproduce this error on Rails 2.3.9. Please run rake db:create on the attached project to reproduce the error.

    February 2nd, 2011 @ 07:21 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from stale to open
    • Milestone set to 2.3.10
    • Assigned user cleared.
    • Importance changed from to Low

    February 2nd, 2011 @ 08:33 PM

  5. Vijay Dev
    Vijay Dev
    • Tag changed from databasesrake, rake_dev to configuration, database.yml, databasesrake, rake_dev
    • Assigned user set to Santiago Pastorino

    The issue seems to be solved when I change the load_config task to depend on the environment task instead of rails_env and remove the assignment to ActiveRecord::Base.configurations. Is this a right approach? How can I test this?

    I would like to know the reasoning behind allowing the path to database.yml to be configurable.

    Also, there is at least one more issue concerning the database.yml path #1710

    February 12th, 2011 @ 07:44 PM

  6. Kandada Boggu
    Kandada Boggu

    We have built a product using Rails framework. Most of our customers/field engineers have no ruby/rails background. When the product is installed, code resides in a directory with read permissions and log/config files reside in a directory with read/write permission. The config directory contain ONLY the files that an administrator can change, i.e. database.yml and app_config.yml. This done in order to avoid any mishaps in production systems.

    This is a common pattern for a corporate deployment. When we deploy on EC2, an EBS volume stores the configuration and log files and AMI has the project source.

    February 13th, 2011 @ 01:14 AM

  7. Santiago Pastorino