online_migrations 0.4.0 → 0.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb5f39f15a73531072b0fe0298a119bd4e9be9ad9c1070fae8fbf21e532f6e20
|
4
|
+
data.tar.gz: a9a3ff44991e42db36f4680cd2bdfc9acd0cf8c8221ff5be999ed53b2266d7ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbb6f4d7455db8c41915520a25b8ae9c94cacb1041cd7111b7d4af3373000c06f647fab0e5bcf43c9fd04af7c13c82b591f7bf7f4fd82048edc07c47860100c
|
7
|
+
data.tar.gz: 2a207fe4cd1ca20b3cf02866445f814e0687249928530aac33062aaf823496b9eb503c9d3bf746236a48e346ea1599518d62004ce2420199407cb381edb87d1d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 0.4.1 (2022-03-21)
|
4
|
+
|
5
|
+
- Fix missing options in suggested command for columns removal
|
6
|
+
- Fix retrieving raw postgresql connection
|
7
|
+
|
8
|
+
## 0.4.0 (2022-03-17)
|
9
|
+
|
3
10
|
- Lazy load this gem
|
4
11
|
|
5
12
|
- Add ability to reset counter caches using background migrations
|
@@ -110,7 +110,7 @@ module OnlineMigrations
|
|
110
110
|
column_options = options[column_name] || {}
|
111
111
|
tmp_column_name = conversions[column_name]
|
112
112
|
|
113
|
-
if
|
113
|
+
if raw_connection.server_version >= 11_00_00 &&
|
114
114
|
primary_key(table_name) == column_name.to_s && old_col.type == :integer
|
115
115
|
# If the column to be converted is a Primary Key, set it to
|
116
116
|
# `NOT NULL DEFAULT 0` and we'll copy the correct values when backfilling.
|
@@ -381,7 +381,7 @@ module OnlineMigrations
|
|
381
381
|
raise_error :remove_column,
|
382
382
|
model: table_name.to_s.classify,
|
383
383
|
columns: columns.inspect,
|
384
|
-
command: command_str(command, *args),
|
384
|
+
command: command_str(command, *args, options),
|
385
385
|
table_name: table_name.inspect,
|
386
386
|
indexes: indexes.map { |i| i.name.to_sym.inspect }
|
387
387
|
end
|
@@ -592,7 +592,7 @@ module OnlineMigrations
|
|
592
592
|
target_version.to_s
|
593
593
|
else
|
594
594
|
# For rails 6.0+ we can use connection.database_version
|
595
|
-
pg_connection = connection.
|
595
|
+
pg_connection = connection.raw_connection
|
596
596
|
database_version = pg_connection.server_version
|
597
597
|
patch = database_version % 100
|
598
598
|
database_version /= 100
|
@@ -396,7 +396,7 @@ module OnlineMigrations
|
|
396
396
|
raise ArgumentError, "Expressions as default are not supported"
|
397
397
|
end
|
398
398
|
|
399
|
-
if
|
399
|
+
if raw_connection.server_version >= 11_00_00 && !Utils.volatile_default?(self, type, default)
|
400
400
|
add_column(table_name, column_name, type, **options)
|
401
401
|
else
|
402
402
|
__ensure_not_in_transaction!
|
@@ -422,7 +422,7 @@ module OnlineMigrations
|
|
422
422
|
add_not_null_constraint(table_name, column_name, validate: false)
|
423
423
|
validate_not_null_constraint(table_name, column_name)
|
424
424
|
|
425
|
-
if
|
425
|
+
if raw_connection.server_version >= 12_00_00
|
426
426
|
# In PostgreSQL 12+ it is safe to "promote" a CHECK constraint to `NOT NULL` for the column
|
427
427
|
change_column_null(table_name, column_name, false)
|
428
428
|
remove_not_null_constraint(table_name, column_name)
|
@@ -1046,14 +1046,5 @@ module OnlineMigrations
|
|
1046
1046
|
_, schema = table_name.to_s.split(".").reverse
|
1047
1047
|
schema ? quote(schema) : "current_schema()"
|
1048
1048
|
end
|
1049
|
-
|
1050
|
-
def __raw_connection
|
1051
|
-
# ActiveRecord > 7.0.2.2 (https://github.com/rails/rails/pull/44530)
|
1052
|
-
if defined?(@raw_connection)
|
1053
|
-
@raw_connection
|
1054
|
-
else
|
1055
|
-
@connection
|
1056
|
-
end
|
1057
|
-
end
|
1058
1049
|
end
|
1059
1050
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|