Skip to content

Commit

Permalink
Only load db/schema.rb if it exists; otherwise, display a message to …
Browse files Browse the repository at this point in the history
…run db:migrate or remove active_record in environment.rb.

[#3012 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
technicalpickles authored and jeremy committed Aug 10, 2009
1 parent 15fd67e commit ebb6606
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion railties/lib/tasks/databases.rake
Expand Up @@ -256,7 +256,11 @@ namespace :db do
desc "Load a schema.rb file into the database"
task :load => :environment do
file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
load(file)
if File.exists?(file)
load(file)
else
abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{RAILS_ROOT}/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]}
end
end
end

Expand Down

0 comments on commit ebb6606

Please sign in to comment.