online_migrations 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8952366397c54505f364a353dde1d68e988ac4773e9b3663de790a75c8b860f3
4
- data.tar.gz: 376dc6e760a2b07d55968a11097f9f81067bc72291718938d1102fafb46a73ea
3
+ metadata.gz: 296a1517b032cbd6d5fa3948f60f1a4f20c4142c8f4c7676c43998f9e941925d
4
+ data.tar.gz: f61a7c6728a6ea1e834be61187b61e3ddf004f4314003752ec3ccf9a5b79afd9
5
5
  SHA512:
6
- metadata.gz: 3e40ed5ab49e5d702c7d7cfebdb4264621375ad9affb67e8c3592814c4a832e75929c4ff718ce90709e64497226df3d9503a42babf56cfaad5ce973026f71d82
7
- data.tar.gz: cdcbc9c26ac23fb975f21dd58c9826dab59c9571d074da06211dea2ffae72c3c57372722110ecd729ba649f21db551f58e8ca43689214f1235cd20669f033cf6
6
+ metadata.gz: fd04da6b57f9862726ee45e6ed13b1032632099a089e26e691717b2e93009269b7f8a8cf3c828501ef97a86d3d13731d4cadb77d0b48f0cf25fea172502780c1
7
+ data.tar.gz: '089a7f40afc28b9671669764ee98c760e4ee8649aab67a4d814b22ca8f5c52cf76afc8a5c9f95244d8be7b879d2b714fa38f07fff3c741bcc91e450077c96801'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.14.0 (2024-02-01)
4
+
5
+ - Add ability to configure whether background migrations should be run inline
6
+
7
+ The previous behavior of running inline in development and test environments is preserved, unless overriden.
8
+
9
+ ```ruby
10
+ config.run_background_migrations_inline = -> { Rails.env.local? }
11
+ ```
12
+
3
13
  ## 0.13.1 (2024-01-23)
4
14
 
5
15
  - Fix calculation of batch ranges for background migration created with explicit ranges
data/docs/configuring.md CHANGED
@@ -214,6 +214,17 @@ Add to an initializer file:
214
214
  config.auto_analyze = true
215
215
  ```
216
216
 
217
+ ### Running background migrations inline
218
+
219
+ `config.run_background_migrations_inline` can be configured with a proc to decide whether background migrations should be run inline. For convenience defaults to true for development and test environments.
220
+
221
+ ```ruby
222
+ # config/initializers/online_migrations.rb
223
+ config.run_background_migrations_inline = -> { Rails.env.local? }
224
+ ```
225
+
226
+ Set to `nil` to avoid running background migrations inline.
227
+
217
228
  ## Schema Sanity
218
229
 
219
230
  Columns can flip order in `db/schema.rb` when you have multiple developers. One way to prevent this is to [alphabetize them](https://www.pgrs.net/2008/03/12/alphabetize-schema-rb-columns/).
@@ -77,6 +77,10 @@ OnlineMigrations.configure do |config|
77
77
  # end
78
78
  # end
79
79
 
80
+ # Decide whether background migrations should be run inline.
81
+ # Convenient for development and test environments.
82
+ config.run_background_migrations_inline = -> { Rails.env.local? }
83
+
80
84
  # ==> Background migrations configuration
81
85
 
82
86
  # The path where generated background migrations will be placed.
@@ -372,8 +372,8 @@ module OnlineMigrations
372
372
  def enqueue_background_migration(migration_name, *arguments, **options)
373
373
  migration = create_background_migration(migration_name, *arguments, **options)
374
374
 
375
- # For convenience in dev/test environments
376
- if Utils.developer_env?
375
+ run_inline = OnlineMigrations.config.run_background_migrations_inline
376
+ if run_inline && run_inline.call
377
377
  runner = MigrationRunner.new(migration)
378
378
  runner.run_all_migration_jobs
379
379
  end
@@ -171,6 +171,16 @@ module OnlineMigrations
171
171
  #
172
172
  attr_accessor :verbose_sql_logs
173
173
 
174
+ # The proc which decides whether background migrations should be run inline.
175
+ # For convenience defaults to true for development and test environments.
176
+ #
177
+ # @example
178
+ # OnlineMigrations.config.run_background_migrations_inline = -> { Rails.env.local? }
179
+ #
180
+ # @return [Proc]
181
+ #
182
+ attr_accessor :run_background_migrations_inline
183
+
174
184
  # Configuration object to configure background migrations
175
185
  #
176
186
  # @return [BackgroundMigrationsConfig]
@@ -202,6 +212,7 @@ module OnlineMigrations
202
212
  @alphabetize_schema = false
203
213
  @enabled_checks = @error_messages.keys.index_with({})
204
214
  @verbose_sql_logs = defined?(Rails.env) && (Rails.env.production? || Rails.env.staging?)
215
+ @run_background_migrations_inline = -> { Utils.developer_env? }
205
216
  end
206
217
 
207
218
  def lock_retrier=(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.13.1"
4
+ VERSION = "0.14.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: online_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord