Skip to content
This repository
Browse code

Only load db/schema.rb if it exists; otherwise, display a message to …

…run db:migrate or remove active_record in environment.rb.

[#3012 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit 84d24cdae8269a161d36e00009c043bbd102cbbd 1 parent 279b785
Josh Nichols technicalpickles authored jeremy committed

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 1 railties/lib/tasks/databases.rake
6 railties/lib/tasks/databases.rake
@@ -292,7 +292,11 @@ namespace :db do
292 292 desc "Load a schema.rb file into the database"
293 293 task :load => :environment do
294 294 file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
295   - load(file)
  295 + if File.exists?(file)
  296 + load(file)
  297 + else
  298 + 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 ]}
  299 + end
296 300 end
297 301 end
298 302

0 comments on commit 84d24cd

Please sign in to comment.
Something went wrong with that request. Please try again.