online_migrations 0.27.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/docs/0.27-upgrade.md +2 -2
- data/lib/online_migrations/background_data_migrations/migration_job.rb +6 -4
- data/lib/online_migrations/change_column_type_helpers.rb +14 -2
- data/lib/online_migrations/error_messages.rb +2 -0
- data/lib/online_migrations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3658cc979ead6b8dea71140f3ba95b0f7a4a4c26a27891f49a5b6925c94e59
|
4
|
+
data.tar.gz: 7d3ab5e09422e28078543ac67fa0ecae1a7afe9d8e29f67e55d6b772fb708e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ae3f3ebffa5491d4ac9b99b987b048702b9142e9a4ae49182b705b9c81a562acbea6dc1580ef76e49a9124adf2d662723451b6d03003f10f05c1d39ff4a33e
|
7
|
+
data.tar.gz: 5793df9ffd71454f2edb251d079439c5dfb0cfe212a30360654cbb5622c23fcd47a63e2a8cdd6b8d4df2bd7d3b39ec4d29eede4a99519264075e65956bdd1b55
|
data/CHANGELOG.md
CHANGED
data/docs/0.27-upgrade.md
CHANGED
@@ -9,7 +9,7 @@ To upgrade:
|
|
9
9
|
* Upgrade gem to v0.27: `gem 'online_migrations', '~> 0.27.0'`
|
10
10
|
* Upgrade the gem's initializer in `config/online_migrations.rb` by referring to the [newest contents](https://github.com/fatkodima/online_migrations/blob/master/lib/generators/online_migrations/templates/initializer.rb.tt)
|
11
11
|
|
12
|
-
If you don't use any of the [background data migrations](
|
12
|
+
If you don't use any of the [background data migrations](background_data_migrations.md) or [background schema migrations](background_schema_migrations.md), then this is probably all you need.
|
13
13
|
|
14
14
|
If you use background data migrations:
|
15
15
|
|
@@ -21,4 +21,4 @@ If you use background data migrations:
|
|
21
21
|
$ bin/rails db:migrate
|
22
22
|
```
|
23
23
|
|
24
|
-
Look at [background data migrations guide](
|
24
|
+
Look at [background data migrations guide](background_data_migrations.md) to find the API changes and new features.
|
@@ -45,10 +45,6 @@ module OnlineMigrations
|
|
45
45
|
@migration.start
|
46
46
|
end
|
47
47
|
|
48
|
-
def around_iteration(&block)
|
49
|
-
@migration.on_shard_if_present(&block)
|
50
|
-
end
|
51
|
-
|
52
48
|
def on_resume
|
53
49
|
@data_migration.after_resume
|
54
50
|
end
|
@@ -140,6 +136,12 @@ module OnlineMigrations
|
|
140
136
|
end
|
141
137
|
|
142
138
|
private
|
139
|
+
# It would be better for sidekiq to have a callback like `around_perform`,
|
140
|
+
# but currently this is the way to make job iteration shard aware.
|
141
|
+
def iterate_with_enumerator(enumerator, arguments)
|
142
|
+
@migration.on_shard_if_present { super }
|
143
|
+
end
|
144
|
+
|
143
145
|
THROTTLE_CHECK_INTERVAL = 5 # seconds
|
144
146
|
private_constant :THROTTLE_CHECK_INTERVAL
|
145
147
|
|
@@ -152,7 +152,11 @@ module OnlineMigrations
|
|
152
152
|
# revert_initialize_column_type_change(:files, :size)
|
153
153
|
#
|
154
154
|
def revert_initialize_column_type_change(table_name, column_name, _new_type = nil, **_options)
|
155
|
-
|
155
|
+
tmp_column_name = __change_type_column(column_name)
|
156
|
+
transaction do
|
157
|
+
__remove_copy_triggers(table_name, column_name, tmp_column_name)
|
158
|
+
remove_column(table_name, tmp_column_name)
|
159
|
+
end
|
156
160
|
end
|
157
161
|
|
158
162
|
# Same as `revert_initialize_column_type_change` but for multiple columns.
|
@@ -160,7 +164,12 @@ module OnlineMigrations
|
|
160
164
|
#
|
161
165
|
def revert_initialize_columns_type_change(table_name, columns_and_types, **_options)
|
162
166
|
column_names = columns_and_types.map(&:first)
|
163
|
-
|
167
|
+
tmp_column_names = column_names.map { |column_name| __change_type_column(column_name) }
|
168
|
+
|
169
|
+
transaction do
|
170
|
+
__remove_copy_triggers(table_name, column_names, tmp_column_names)
|
171
|
+
remove_columns(table_name, *tmp_column_names)
|
172
|
+
end
|
164
173
|
end
|
165
174
|
|
166
175
|
# Backfills data from the old column to the new column.
|
@@ -347,6 +356,7 @@ module OnlineMigrations
|
|
347
356
|
# the original column type to be able to revert.
|
348
357
|
#
|
349
358
|
def cleanup_column_type_change(table_name, column_name)
|
359
|
+
__ensure_not_in_transaction!
|
350
360
|
cleanup_columns_type_change(table_name, column_name)
|
351
361
|
end
|
352
362
|
|
@@ -354,6 +364,8 @@ module OnlineMigrations
|
|
354
364
|
# @see #cleanup_column_type_change
|
355
365
|
#
|
356
366
|
def cleanup_columns_type_change(table_name, *column_names)
|
367
|
+
__ensure_not_in_transaction!
|
368
|
+
|
357
369
|
tmp_column_names = column_names.map { |column_name| __change_type_column(column_name) }
|
358
370
|
|
359
371
|
# Safely remove existing indexes and foreign keys first, if any.
|
@@ -230,6 +230,8 @@ during writes works automatically). For most column type changes, this does not
|
|
230
230
|
7. Finally, if everything works as expected, remove copy trigger and old column:
|
231
231
|
|
232
232
|
class Cleanup<%= migration_name %> < <%= migration_parent %>
|
233
|
+
disable_ddl_transaction!
|
234
|
+
|
233
235
|
def up
|
234
236
|
<%= cleanup_code %>
|
235
237
|
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.27.
|
4
|
+
version: 0.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|