diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-26 12:27:58 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-26 12:27:58 -0600 |
commit | 04bc52f7dc4c264fd1825d565e058047c58bb694 (patch) | |
tree | 4ed8315bdb6429636db4b604555e505069de769a /activerecord/lib/active_record | |
parent | 67b8f92743273370beca4d9c089ed9412fbfe940 (diff) | |
parent | f33965f937044b01a472ed3cea14f0a401abaad4 (diff) | |
download | rails-04bc52f7dc4c264fd1825d565e058047c58bb694.tar.gz rails-04bc52f7dc4c264fd1825d565e058047c58bb694.tar.bz2 rails-04bc52f7dc4c264fd1825d565e058047c58bb694.zip |
Merge pull request #19924 from iamvery/db-tasks-exit-status
Explicitly exit with status "1" for create and drop failures
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/sqlite_database_tasks.rb | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index ea7927a435..c0c29a618c 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -94,8 +94,9 @@ module ActiveRecord rescue DatabaseAlreadyExists $stderr.puts "#{configuration['database']} already exists" rescue Exception => error - $stderr.puts error, *(error.backtrace) + $stderr.puts error $stderr.puts "Couldn't create database for #{configuration.inspect}" + raise end def create_all @@ -115,8 +116,9 @@ module ActiveRecord rescue ActiveRecord::NoDatabaseError $stderr.puts "Database '#{configuration['database']}' does not exist" rescue Exception => error - $stderr.puts error, *(error.backtrace) + $stderr.puts error $stderr.puts "Couldn't drop #{configuration['database']}" + raise end def drop_all diff --git a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb index 9ab64d0325..9ec3c8a94a 100644 --- a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb @@ -19,11 +19,15 @@ module ActiveRecord path = Pathname.new configuration['database'] file = path.absolute? ? path.to_s : File.join(root, path) - FileUtils.rm(file) if File.exist?(file) + FileUtils.rm(file) + rescue Errno::ENOENT => error + raise NoDatabaseError.new(error.message, error) end def purge drop + rescue NoDatabaseError + ensure create end |