提交 84d24cda 编写于 作者: J Joshua Nichols 提交者: Jeremy Kemper

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

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: NJeremy Kemper <jeremy@bitsweat.net>
上级 279b7858
......@@ -292,7 +292,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册