strong_migrations 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fac153e8505e25b50796c4033952d7e3a0b50db1f0a1fadfd3d3c19e72ac669b
4
- data.tar.gz: fc7823c9b58f8598f7a5fee9bc9886e6a7cf444cf853da26fb9b6bc960a09dc9
3
+ metadata.gz: 4c0ea5c8cf3e904b89b8c4ab2f28ff60031515e40edf5b0c617ca4b8f8249650
4
+ data.tar.gz: 5cb0fd63058bf618595cd929ef90de3cf90f02963f0adca21182c578f41c3320
5
5
  SHA512:
6
- metadata.gz: 4cfb16530dce0d416b54ab87b333926299eaccd84a059d270809fb98a576a489f6d250fe7cb008f9471b0f992819cc6bc9efa90c337c78bd7bb53282cc4758e8
7
- data.tar.gz: d1aa24bb732b617a4208ac95eafa206c4e3af1782793a7007a89c57894fc2e6a38abccf9e6289f53be1ceda436392bdce08e3cc52be7c70c3b942ea896aaec21
6
+ metadata.gz: 50db9d240d49b60b75d97c76765b8f5e3b252c2cc826bd5e50e9b57311082dfea2c9cc5790fd905a2eac45a3eb6afb2784c7ed7962dcaf0172157548e1c8d233
7
+ data.tar.gz: 2f2e5311cad061b712ee9dfb69a41b5e81f31be8db257bd095cbd8124bc461551afebb305d95b0bb090d6f7ef85c61618d61e64e9b73f266338a0aa7f5101b53
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.2.0 (2022-06-10)
2
+
3
+ - Added check for index corruption with Postgres 14.0 to 14.3
4
+
1
5
  ## 1.1.0 (2022-06-08)
2
6
 
3
7
  - Added check for `force` option with `create_join_table`
@@ -13,11 +13,10 @@ module StrongMigrations
13
13
  @version ||= begin
14
14
  target_version(StrongMigrations.target_postgresql_version) do
15
15
  version = select_all("SHOW server_version_num").first["server_version_num"].to_i
16
+ # major and minor version
16
17
  if version >= 100000
17
- # major version for 10+
18
- "#{version / 10000}"
18
+ "#{version / 10000}.#{(version % 10000)}"
19
19
  else
20
- # major and minor version for < 10
21
20
  "#{version / 10000}.#{(version % 10000) / 100}"
22
21
  end
23
22
  end
@@ -160,6 +159,13 @@ module StrongMigrations
160
159
  select_all(query.squish).any?
161
160
  end
162
161
 
162
+ # only check in non-developer environments (where actual server version is used)
163
+ def index_corruption?
164
+ server_version >= Gem::Version.new("14.0") &&
165
+ server_version < Gem::Version.new("14.4") &&
166
+ !StrongMigrations.developer_env?
167
+ end
168
+
163
169
  private
164
170
 
165
171
  def set_timeout(setting, timeout)
@@ -98,6 +98,11 @@ Then add the NOT NULL constraint in separate migrations."
98
98
  raise_error :add_index_columns, header: "Best practice"
99
99
  end
100
100
 
101
+ # safe_by_default goes through this path as well
102
+ if postgresql? && options[:algorithm] == :concurrently && adapter.index_corruption?
103
+ raise_error :add_index_corruption
104
+ end
105
+
101
106
  # safe to add non-concurrently to new tables (even after inserting data)
102
107
  # since the table won't be in use by the application
103
108
  if postgresql? && options[:algorithm] != :concurrently && !new_table?(table)
@@ -128,6 +128,11 @@ end",
128
128
  "Adding a non-unique index with more than three columns rarely improves performance.
129
129
  Instead, start an index with columns that narrow down the results the most.",
130
130
 
131
+ add_index_corruption:
132
+ "Adding an index concurrently can cause silent data corruption in Postgres 14.0 to 14.3.
133
+ Upgrade Postgres before adding new indexes, or wrap this step in a safety_assured { ... } block
134
+ to accept the risk.",
135
+
131
136
  change_table:
132
137
  "Strong Migrations does not support inspecting what happens inside a
133
138
  change_table block, so cannot help you here. Please make really sure that what
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-06-09 00:00:00.000000000 Z
13
+ date: 2022-06-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord