diff options
author | Ralin Chimev <ralin.chimev@gmail.com> | 2016-05-10 20:44:33 +0300 |
---|---|---|
committer | Ralin Chimev <ralin.chimev@gmail.com> | 2016-05-10 22:23:44 +0300 |
commit | 09a90bb6a06b1dafc9881651f585e8b40dda4227 (patch) | |
tree | 779fe084eb1539d5ef35509b4ae00dc0c2a0b0fe /activerecord/lib | |
parent | 932655a4ef61083da98724bb612d00f89e153c46 (diff) | |
download | rails-09a90bb6a06b1dafc9881651f585e8b40dda4227.tar.gz rails-09a90bb6a06b1dafc9881651f585e8b40dda4227.tar.bz2 rails-09a90bb6a06b1dafc9881651f585e8b40dda4227.zip |
PostgreSQL: Fix db:structure:load silent failure on SQL error
The command line flag "-v ON_ERROR_STOP=1" should be used when invoking psql to make sure errors are not suppressed.
Example: psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db
Fixes #23818.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/tasks/postgresql_database_tasks.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb index 8b4874044c..b19ab57ee4 100644 --- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb @@ -2,6 +2,7 @@ module ActiveRecord module Tasks # :nodoc: class PostgreSQLDatabaseTasks # :nodoc: DEFAULT_ENCODING = ENV['CHARSET'] || 'utf8' + ON_ERROR_STOP_1 = 'ON_ERROR_STOP=1'.freeze delegate :connection, :establish_connection, :clear_active_connections!, to: ActiveRecord::Base @@ -67,7 +68,7 @@ module ActiveRecord def structure_load(filename) set_psql_env - args = [ '-q', '-f', filename, configuration['database'] ] + args = [ '-v', ON_ERROR_STOP_1, '-q', '-f', filename, configuration['database'] ] run_cmd('psql', args, 'loading' ) end |