Permalink
Browse files

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...
1 parent 15fd67e commit ebb6606a4d09ca362a0c56a458444a8dd551c495 @technicalpickles technicalpickles committed with jeremy Aug 8, 2009
Showing with 5 additions and 1 deletion.
  1. +5 −1 railties/lib/tasks/databases.rake
@@ -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

0 comments on commit ebb6606

Please sign in to comment.