hanami-model 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +6 -3
  5. data/hanami-model.gemspec +25 -21
  6. data/lib/hanami-model.rb +3 -1
  7. data/lib/hanami/entity.rb +5 -3
  8. data/lib/hanami/entity/schema.rb +9 -7
  9. data/lib/hanami/model.rb +14 -12
  10. data/lib/hanami/model/association.rb +7 -7
  11. data/lib/hanami/model/associations/belongs_to.rb +3 -1
  12. data/lib/hanami/model/associations/dsl.rb +2 -2
  13. data/lib/hanami/model/associations/has_many.rb +10 -8
  14. data/lib/hanami/model/associations/has_one.rb +9 -7
  15. data/lib/hanami/model/associations/many_to_many.rb +9 -11
  16. data/lib/hanami/model/configuration.rb +15 -13
  17. data/lib/hanami/model/configurator.rb +5 -3
  18. data/lib/hanami/model/entity_name.rb +3 -1
  19. data/lib/hanami/model/error.rb +9 -7
  20. data/lib/hanami/model/mapped_relation.rb +4 -2
  21. data/lib/hanami/model/mapping.rb +3 -1
  22. data/lib/hanami/model/migration.rb +2 -0
  23. data/lib/hanami/model/migrator.rb +7 -5
  24. data/lib/hanami/model/migrator/adapter.rb +13 -11
  25. data/lib/hanami/model/migrator/connection.rb +10 -8
  26. data/lib/hanami/model/migrator/logger.rb +3 -1
  27. data/lib/hanami/model/migrator/mysql_adapter.rb +23 -13
  28. data/lib/hanami/model/migrator/postgres_adapter.rb +30 -28
  29. data/lib/hanami/model/migrator/sqlite_adapter.rb +7 -9
  30. data/lib/hanami/model/plugins.rb +5 -3
  31. data/lib/hanami/model/plugins/mapping.rb +2 -0
  32. data/lib/hanami/model/plugins/schema.rb +2 -0
  33. data/lib/hanami/model/plugins/timestamps.rb +2 -0
  34. data/lib/hanami/model/relation_name.rb +4 -2
  35. data/lib/hanami/model/sql.rb +9 -7
  36. data/lib/hanami/model/sql/console.rb +10 -8
  37. data/lib/hanami/model/sql/consoles/abstract.rb +3 -1
  38. data/lib/hanami/model/sql/consoles/mysql.rb +4 -2
  39. data/lib/hanami/model/sql/consoles/postgresql.rb +10 -8
  40. data/lib/hanami/model/sql/consoles/sqlite.rb +6 -4
  41. data/lib/hanami/model/sql/entity/schema.rb +6 -4
  42. data/lib/hanami/model/sql/types.rb +7 -5
  43. data/lib/hanami/model/sql/types/schema/coercions.rb +5 -4
  44. data/lib/hanami/model/types.rb +4 -4
  45. data/lib/hanami/model/version.rb +3 -1
  46. data/lib/hanami/repository.rb +20 -31
  47. metadata +34 -3
@@ -1,4 +1,6 @@
1
- require 'rom/configuration'
1
+ # frozen_string_literal: true
2
+
3
+ require "rom/configuration"
2
4
 
3
5
  module Hanami
4
6
  module Model
@@ -30,13 +32,13 @@ module Hanami
30
32
  def initialize(configurator)
31
33
  @backend = configurator.backend
32
34
  @url = configurator.url
33
- @migrations = configurator._migrations
34
- @schema = configurator._schema
35
- @gateway_config = configurator._gateway
36
- @logger = configurator._logger
35
+ @migrations = configurator._migrations
36
+ @schema = configurator._schema
37
+ @gateway_config = configurator._gateway
38
+ @logger = configurator._logger
37
39
  @migrations_logger = configurator.migrations_logger
38
- @mappings = {}
39
- @entities = {}
40
+ @mappings = {}
41
+ @entities = {}
40
42
  end
41
43
 
42
44
  # NOTE: This must be changed when we want to support several adapters at the time
@@ -136,10 +138,10 @@ module Hanami
136
138
  # @api private
137
139
  def rom
138
140
  @rom ||= ROM::Configuration.new(@backend, @url, infer_relations: false)
139
- rescue => e
140
- raise UnknownDatabaseAdapterError.new(@url) if e.message =~ /adapters/
141
+ rescue => exception
142
+ raise UnknownDatabaseAdapterError.new(@url) if exception.message =~ /adapters/
141
143
 
142
- raise e
144
+ raise exception
143
145
  end
144
146
 
145
147
  # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
@@ -147,7 +149,7 @@ module Hanami
147
149
  #
148
150
  # @since 1.0.0
149
151
  # @api private
150
- def load!(repositories, &blk) # rubocop:disable Metrics/AbcSize
152
+ def load!(repositories, &blk)
151
153
  rom.setup.auto_registration(config.directory.to_s) unless config.directory.nil?
152
154
  rom.instance_eval(&blk) if block_given?
153
155
  configure_gateway
@@ -157,8 +159,8 @@ module Hanami
157
159
  container = ROM.container(rom)
158
160
  define_entities_mappings(container, repositories)
159
161
  container
160
- rescue => e
161
- raise Hanami::Model::Error.for(e)
162
+ rescue => exception
163
+ raise Hanami::Model::Error.for(exception)
162
164
  end
163
165
 
164
166
  # @since 1.0.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  # Configuration DSL
@@ -42,7 +44,7 @@ module Hanami
42
44
  # @since 1.0.0
43
45
  # @api private
44
46
  def migrations_logger(stream = $stdout)
45
- require 'hanami/model/migrator/logger'
47
+ require "hanami/model/migrator/logger"
46
48
  @migrations_logger ||= Hanami::Model::Migrator::Logger.new(stream)
47
49
  end
48
50
 
@@ -76,10 +78,10 @@ module Hanami
76
78
  # @since 1.0.0
77
79
  # @api private
78
80
  def logger(stream, options = {})
79
- require 'hanami/logger'
81
+ require "hanami/logger"
80
82
 
81
83
  opts = options.merge(stream: stream)
82
- @_logger = Hanami::Logger.new('hanami.model', opts)
84
+ @_logger = Hanami::Logger.new("hanami.model", **opts)
83
85
  end
84
86
 
85
87
  # @since 1.0.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  # Conventional name for entities.
@@ -18,7 +20,7 @@ module Hanami
18
20
  # @since 0.7.0
19
21
  # @api private
20
22
  def initialize(name)
21
- @name = name.sub(SUFFIX, '')
23
+ @name = name.sub(SUFFIX, "")
22
24
  end
23
25
 
24
26
  # @since 0.7.0
@@ -1,4 +1,6 @@
1
- require 'concurrent'
1
+ # frozen_string_literal: true
2
+
3
+ require "concurrent"
2
4
 
3
5
  module Hanami
4
6
  module Model
@@ -41,7 +43,7 @@ module Hanami
41
43
  class InvalidCommandError < Error
42
44
  # @since 0.5.0
43
45
  # @api private
44
- def initialize(message = 'Invalid command')
46
+ def initialize(message = "Invalid command")
45
47
  super
46
48
  end
47
49
  end
@@ -52,7 +54,7 @@ module Hanami
52
54
  class ConstraintViolationError < Error
53
55
  # @since 0.7.0
54
56
  # @api private
55
- def initialize(message = 'Constraint has been violated')
57
+ def initialize(message = "Constraint has been violated")
56
58
  super
57
59
  end
58
60
  end
@@ -63,7 +65,7 @@ module Hanami
63
65
  class UniqueConstraintViolationError < ConstraintViolationError
64
66
  # @since 0.6.1
65
67
  # @api private
66
- def initialize(message = 'Unique constraint has been violated')
68
+ def initialize(message = "Unique constraint has been violated")
67
69
  super
68
70
  end
69
71
  end
@@ -74,7 +76,7 @@ module Hanami
74
76
  class ForeignKeyConstraintViolationError < ConstraintViolationError
75
77
  # @since 0.6.1
76
78
  # @api private
77
- def initialize(message = 'Foreign key constraint has been violated')
79
+ def initialize(message = "Foreign key constraint has been violated")
78
80
  super
79
81
  end
80
82
  end
@@ -85,7 +87,7 @@ module Hanami
85
87
  class NotNullConstraintViolationError < ConstraintViolationError
86
88
  # @since 0.6.1
87
89
  # @api private
88
- def initialize(message = 'NOT NULL constraint has been violated')
90
+ def initialize(message = "NOT NULL constraint has been violated")
89
91
  super
90
92
  end
91
93
  end
@@ -96,7 +98,7 @@ module Hanami
96
98
  class CheckConstraintViolationError < ConstraintViolationError
97
99
  # @since 0.6.1
98
100
  # @api private
99
- def initialize(message = 'Check constraint has been violated')
101
+ def initialize(message = "Check constraint has been violated")
100
102
  super
101
103
  end
102
104
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  # Mapped proxy for ROM relations.
@@ -51,8 +53,8 @@ module Hanami
51
53
  # end
52
54
  def [](attribute)
53
55
  @relation[attribute]
54
- rescue KeyError => e
55
- raise UnknownAttributeError.new(e.message)
56
+ rescue KeyError => exception
57
+ raise UnknownAttributeError.new(exception.message)
56
58
  end
57
59
  end
58
60
  end
@@ -1,4 +1,6 @@
1
- require 'transproc/all'
1
+ # frozen_string_literal: true
2
+
3
+ require "transproc/all"
2
4
 
3
5
  module Hanami
4
6
  module Model
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  # Database migration
@@ -1,5 +1,7 @@
1
- require 'sequel'
2
- require 'sequel/extensions/migration'
1
+ # frozen_string_literal: true
2
+
3
+ require "sequel"
4
+ require "sequel/extensions/migration"
3
5
 
4
6
  module Hanami
5
7
  module Model
@@ -13,8 +15,8 @@ module Hanami
13
15
  #
14
16
  # @since 0.4.0
15
17
  class Migrator
16
- require 'hanami/model/migrator/connection'
17
- require 'hanami/model/migrator/adapter'
18
+ require "hanami/model/migrator/connection"
19
+ require "hanami/model/migrator/adapter"
18
20
 
19
21
  # Create database defined by current configuration.
20
22
  #
@@ -327,7 +329,7 @@ module Hanami
327
329
  # @see Hanami::Model::Migrator.prepare
328
330
  def prepare
329
331
  drop
330
- rescue # rubocop:disable Lint/HandleExceptions
332
+ rescue # rubocop:disable Lint/SuppressedException
331
333
  ensure
332
334
  create
333
335
  adapter.load
@@ -1,6 +1,8 @@
1
- require 'uri'
2
- require 'shellwords'
3
- require 'open3'
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "shellwords"
5
+ require "open3"
4
6
 
5
7
  module Hanami
6
8
  module Model
@@ -26,18 +28,18 @@ module Hanami
26
28
  #
27
29
  # @since 0.4.0
28
30
  # @api private
29
- def self.for(configuration) # rubocop:disable Metrics/MethodLength
31
+ def self.for(configuration)
30
32
  connection = Connection.new(configuration)
31
33
 
32
34
  case connection.database_type
33
35
  when :sqlite
34
- require 'hanami/model/migrator/sqlite_adapter'
36
+ require "hanami/model/migrator/sqlite_adapter"
35
37
  SQLiteAdapter
36
38
  when :postgres
37
- require 'hanami/model/migrator/postgres_adapter'
39
+ require "hanami/model/migrator/postgres_adapter"
38
40
  PostgresAdapter
39
41
  when :mysql
40
- require 'hanami/model/migrator/mysql_adapter'
42
+ require "hanami/model/migrator/mysql_adapter"
41
43
  MySQLAdapter
42
44
  else
43
45
  self
@@ -80,8 +82,8 @@ module Hanami
80
82
  version = Integer(version) unless version.nil?
81
83
 
82
84
  Sequel::Migrator.run(connection.raw, migrations, target: version, allow_missing_migration_files: true)
83
- rescue Sequel::Migrator::Error => e
84
- raise MigrationError.new(e.message)
85
+ rescue Sequel::Migrator::Error => exception
86
+ raise MigrationError.new(exception.message)
85
87
  end
86
88
 
87
89
  # @since 1.1.0
@@ -91,8 +93,8 @@ module Hanami
91
93
  version = version_to_rollback(table, steps)
92
94
 
93
95
  Sequel::Migrator.run(connection.raw, migrations, target: version, allow_missing_migration_files: true)
94
- rescue Sequel::Migrator::Error => e
95
- raise MigrationError.new(e.message)
96
+ rescue Sequel::Migrator::Error => exception
97
+ raise MigrationError.new(exception.message)
96
98
  end
97
99
 
98
100
  # Load database schema.
@@ -1,4 +1,6 @@
1
- require 'cgi'
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
2
4
 
3
5
  module Hanami
4
6
  module Model
@@ -36,7 +38,7 @@ module Hanami
36
38
  # @since 0.5.0
37
39
  # @api private
38
40
  def host
39
- @host ||= parsed_uri.host || parsed_opt('host')
41
+ @host ||= parsed_uri.host || parsed_opt("host")
40
42
  end
41
43
 
42
44
  # Returns DB connection port
@@ -46,7 +48,7 @@ module Hanami
46
48
  # @since 0.5.0
47
49
  # @api private
48
50
  def port
49
- @port ||= parsed_uri.port || parsed_opt('port').to_i.nonzero?
51
+ @port ||= parsed_uri.port || parsed_opt("port").to_i.nonzero?
50
52
  end
51
53
 
52
54
  # Returns DB name from conenction
@@ -85,7 +87,7 @@ module Hanami
85
87
  # @since 0.5.0
86
88
  # @api private
87
89
  def user
88
- @user ||= parsed_opt('user') || parsed_uri.user
90
+ @user ||= parsed_opt("user") || parsed_uri.user
89
91
  end
90
92
 
91
93
  # Returns user from DB connection
@@ -95,7 +97,7 @@ module Hanami
95
97
  # @since 0.5.0
96
98
  # @api private
97
99
  def password
98
- @password ||= parsed_opt('password') || parsed_uri.password
100
+ @password ||= parsed_opt("password") || parsed_uri.password
99
101
  end
100
102
 
101
103
  # Returns DB connection URI directly from adapter
@@ -111,7 +113,7 @@ module Hanami
111
113
  # @since 0.5.0
112
114
  # @api private
113
115
  def global_uri
114
- uri.sub(parsed_uri.select(:path).first, '')
116
+ uri.sub(parsed_uri.select(:path).first, "")
115
117
  end
116
118
 
117
119
  # Returns a boolean telling if a DB connection is from JDBC or not
@@ -119,7 +121,7 @@ module Hanami
119
121
  # @since 0.5.0
120
122
  # @api private
121
123
  def jdbc?
122
- !uri.scan('jdbc:').empty?
124
+ !uri.scan("jdbc:").empty?
123
125
  end
124
126
 
125
127
  # Returns database connection URI instance without JDBC namespace
@@ -127,7 +129,7 @@ module Hanami
127
129
  # @since 0.5.0
128
130
  # @api private
129
131
  def parsed_uri
130
- @parsed_uri ||= URI.parse(uri.sub('jdbc:', ''))
132
+ @parsed_uri ||= URI.parse(uri.sub("jdbc:", ""))
131
133
  end
132
134
 
133
135
  # @api private
@@ -1,4 +1,6 @@
1
- require 'hanami/logger'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/logger"
2
4
 
3
5
  module Hanami
4
6
  module Model
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  class Migrator
@@ -8,23 +10,27 @@ module Hanami
8
10
  class MySQLAdapter < Adapter
9
11
  # @since 0.7.0
10
12
  # @api private
11
- PASSWORD = 'MYSQL_PWD'.freeze
13
+ PASSWORD = "MYSQL_PWD"
14
+
15
+ # @since 1.3.3
16
+ # @api private
17
+ DEFAULT_PORT = 3306
12
18
 
13
19
  # @since 1.0.0
14
20
  # @api private
15
- DB_CREATION_ERROR = 'Database creation failed. If the database exists, ' \
16
- 'then its console may be open. See this issue for more details: ' \
17
- 'https://github.com/hanami/model/issues/250'.freeze
21
+ DB_CREATION_ERROR = "Database creation failed. If the database exists, " \
22
+ "then its console may be open. See this issue for more details: " \
23
+ "https://github.com/hanami/model/issues/250"
18
24
 
19
25
  # @since 0.4.0
20
26
  # @api private
21
27
  def create
22
28
  new_connection(global: true).run %(CREATE DATABASE `#{database}`;)
23
- rescue Sequel::DatabaseError => e
24
- message = if e.message.match(/database exists/) # rubocop:disable Performance/RedundantMatch
29
+ rescue Sequel::DatabaseError => exception
30
+ message = if exception.message.match(/database exists/)
25
31
  DB_CREATION_ERROR
26
32
  else
27
- e.message
33
+ exception.message
28
34
  end
29
35
 
30
36
  raise MigrationError.new(message)
@@ -34,11 +40,11 @@ module Hanami
34
40
  # @api private
35
41
  def drop
36
42
  new_connection(global: true).run %(DROP DATABASE `#{database}`;)
37
- rescue Sequel::DatabaseError => e
38
- message = if e.message.match(/doesn\'t exist/) # rubocop:disable Performance/RedundantMatch
43
+ rescue Sequel::DatabaseError => exception
44
+ message = if exception.message.match(/doesn\'t exist/)
39
45
  "Cannot find database: #{database}"
40
46
  else
41
- e.message
47
+ exception.message
42
48
  end
43
49
 
44
50
  raise MigrationError.new(message)
@@ -65,22 +71,26 @@ module Hanami
65
71
  connection.password
66
72
  end
67
73
 
74
+ def port
75
+ super || DEFAULT_PORT
76
+ end
77
+
68
78
  # @since 0.4.0
69
79
  # @api private
70
80
  def dump_structure
71
- execute "mysqldump --host=#{host} --port=#{port} --user=#{username} --no-data --skip-comments --ignore-table=#{database}.#{migrations_table} #{database} > #{schema}", env: { PASSWORD => password }
81
+ execute "mysqldump --host=#{host} --port=#{port} --user=#{username} --no-data --skip-comments --ignore-table=#{database}.#{migrations_table} #{database} > #{schema}", env: {PASSWORD => password}
72
82
  end
73
83
 
74
84
  # @since 0.4.0
75
85
  # @api private
76
86
  def load_structure
77
- execute("mysql --host=#{host} --port=#{port} --user=#{username} #{database} < #{escape(schema)}", env: { PASSWORD => password }) if schema.exist?
87
+ execute("mysql --host=#{host} --port=#{port} --user=#{username} #{database} < #{escape(schema)}", env: {PASSWORD => password}) if schema.exist?
78
88
  end
79
89
 
80
90
  # @since 0.4.0
81
91
  # @api private
82
92
  def dump_migrations_data
83
- execute "mysqldump --host=#{host} --port=#{port} --user=#{username} --skip-comments #{database} #{migrations_table} >> #{schema}", env: { PASSWORD => password }
93
+ execute "mysqldump --host=#{host} --port=#{port} --user=#{username} --skip-comments #{database} #{migrations_table} >> #{schema}", env: {PASSWORD => password}
84
94
  end
85
95
  end
86
96
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/blank"
4
+
1
5
  module Hanami
2
6
  module Model
3
7
  class Migrator
@@ -8,46 +12,41 @@ module Hanami
8
12
  class PostgresAdapter < Adapter
9
13
  # @since 0.4.0
10
14
  # @api private
11
- HOST = 'PGHOST'.freeze
15
+ HOST = "PGHOST"
12
16
 
13
17
  # @since 0.4.0
14
18
  # @api private
15
- PORT = 'PGPORT'.freeze
19
+ PORT = "PGPORT"
16
20
 
17
21
  # @since 0.4.0
18
22
  # @api private
19
- USER = 'PGUSER'.freeze
23
+ USER = "PGUSER"
20
24
 
21
25
  # @since 0.4.0
22
26
  # @api private
23
- PASSWORD = 'PGPASSWORD'.freeze
27
+ PASSWORD = "PGPASSWORD"
24
28
 
25
29
  # @since 1.0.0
26
30
  # @api private
27
- DB_CREATION_ERROR = 'createdb: database creation failed. If the database exists, ' \
28
- 'then its console may be open. See this issue for more details: ' \
29
- 'https://github.com/hanami/model/issues/250'.freeze
31
+ DB_CREATION_ERROR = "createdb: database creation failed. If the database exists, " \
32
+ "then its console may be open. See this issue for more details: " \
33
+ "https://github.com/hanami/model/issues/250"
30
34
 
31
35
  # @since 0.4.0
32
36
  # @api private
33
37
  def create
34
- set_environment_variables
35
-
36
- call_db_command('createdb')
38
+ call_db_command("createdb")
37
39
  end
38
40
 
39
41
  # @since 0.4.0
40
42
  # @api private
41
43
  def drop
42
- set_environment_variables
43
-
44
- call_db_command('dropdb')
44
+ call_db_command("dropdb")
45
45
  end
46
46
 
47
47
  # @since 0.4.0
48
48
  # @api private
49
49
  def dump
50
- set_environment_variables
51
50
  dump_structure
52
51
  dump_migrations_data
53
52
  end
@@ -55,51 +54,54 @@ module Hanami
55
54
  # @since 0.4.0
56
55
  # @api private
57
56
  def load
58
- set_environment_variables
59
57
  load_structure
60
58
  end
61
59
 
62
60
  private
63
61
 
64
- # @since 0.4.0
62
+ # @since 1.3.3
65
63
  # @api private
66
- def set_environment_variables
67
- ENV[HOST] = host unless host.nil?
68
- ENV[PORT] = port.to_s unless port.nil?
69
- ENV[PASSWORD] = password unless password.nil?
70
- ENV[USER] = username unless username.nil?
64
+ def environment_variables
65
+ {}.tap do |env|
66
+ env[HOST] = host unless host.nil?
67
+ env[PORT] = port.to_s unless port.nil?
68
+ env[PASSWORD] = password unless password.nil?
69
+ env[USER] = username unless username.nil?
70
+ end
71
71
  end
72
72
 
73
73
  # @since 0.4.0
74
74
  # @api private
75
75
  def dump_structure
76
- execute "pg_dump -s -x -O -T #{migrations_table} -f #{escape(schema)} #{database}"
76
+ execute "pg_dump -s -x -O -T #{migrations_table} -f #{escape(schema)} #{database}", env: environment_variables
77
77
  end
78
78
 
79
79
  # @since 0.4.0
80
80
  # @api private
81
81
  def load_structure
82
- execute "psql -X -q -f #{escape(schema)} #{database}" if schema.exist?
82
+ return unless schema.exist?
83
+
84
+ execute "psql -X -q -f #{escape(schema)} #{database}", env: environment_variables
83
85
  end
84
86
 
85
87
  # @since 0.4.0
86
88
  # @api private
87
89
  def dump_migrations_data
88
90
  error = ->(err) { raise MigrationError.new(err) unless err =~ /no matching tables/i }
89
- execute "pg_dump -t #{migrations_table} #{database} >> #{escape(schema)}", error: error
91
+ execute "pg_dump -t #{migrations_table} #{database} >> #{escape(schema)}", error: error, env: environment_variables
90
92
  end
91
93
 
92
94
  # @since 0.5.1
93
95
  # @api private
94
96
  def call_db_command(command)
95
- require 'open3'
97
+ require "open3"
96
98
 
97
99
  begin
98
- Open3.popen3(command, database) do |_stdin, _stdout, stderr, wait_thr|
100
+ Open3.popen3(environment_variables, command, database) do |_stdin, _stdout, stderr, wait_thr|
99
101
  raise MigrationError.new(modified_message(stderr.read)) unless wait_thr.value.success? # wait_thr.value is the exit status
100
102
  end
101
- rescue SystemCallError => e
102
- raise MigrationError.new(modified_message(e.message))
103
+ rescue SystemCallError => exception
104
+ raise MigrationError.new(modified_message(exception.message))
103
105
  end
104
106
  end
105
107