strong_migrations 1.3.1 → 1.3.2

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: b330db9323d9942a9e24a5fdc3ab75931030f859505cb9eef2f428df840b4dcc
4
- data.tar.gz: 8aa1acd2debbc49206cf9b3928c16e85d4f2f47140142d4e9b981d1d54254e12
3
+ metadata.gz: 227ddfd8f939d855d93232f5d30d02a0c219f46c6393d98e2be5d8756c445e33
4
+ data.tar.gz: bde562f14e23d1fc7a1209e075efffad03454594b842bcde3c7b1ec6fa3046b4
5
5
  SHA512:
6
- metadata.gz: 2bce01385b02f0c005cae82cda4325f5332b400949cc0c5814a25c4bc30f78ff0a66730179dc52458bae242aa5cc4d1eb6be755696c731521580b3554f3eee6c
7
- data.tar.gz: 72bcd4096a69bd3c8afd78caa43651b10bf5924318635adeb52308724751fa9fdbaeaa59e07a690a4a0915524afbab3487a8f1db17086c18e0b742c0d3de6b28
6
+ metadata.gz: 972103d956c2a8cdff88e478401f18459eabe93d7260107b5c19908cc76bef9451b19e99852511d8a8675639b076107d79d26a6046308d4627afc88f580afc76
7
+ data.tar.gz: 3bf1e422cf0d5cd4297bf63a6121570e5afa9acddccf42c4fa7a21eac40fa0cc6d5fca04e2227a45132d7efde0b7f702bb90f3be916097079f9b569cdd04ba50
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.3.2 (2022-10-09)
2
+
3
+ - Improved error message for `add_column` with `default: nil` with Postgres 10
4
+
1
5
  ## 1.3.1 (2022-09-21)
2
6
 
3
7
  - Fixed check for `add_column` with `default: nil` with Postgres 10
@@ -44,14 +44,21 @@ module StrongMigrations
44
44
  Then add the NOT NULL constraint in separate migrations."
45
45
  end
46
46
 
47
- raise_error :add_column_default,
48
- add_command: command_str("add_column", [table, column, type, options.except(:default)]),
49
- change_command: command_str("change_column_default", [table, column, default]),
50
- remove_command: command_str("remove_column", [table, column]),
51
- code: backfill_code(table, column, default, volatile),
52
- append: append,
53
- rewrite_blocks: adapter.rewrite_blocks,
54
- default_type: (volatile ? "volatile" : "non-null")
47
+ if default.nil?
48
+ raise_error :add_column_default_null,
49
+ command: command_str("add_column", [table, column, type, options.except(:default)]),
50
+ append: append,
51
+ rewrite_blocks: adapter.rewrite_blocks
52
+ else
53
+ raise_error :add_column_default,
54
+ add_command: command_str("add_column", [table, column, type, options.except(:default)]),
55
+ change_command: command_str("change_column_default", [table, column, default]),
56
+ remove_command: command_str("remove_column", [table, column]),
57
+ code: backfill_code(table, column, default, volatile),
58
+ append: append,
59
+ rewrite_blocks: adapter.rewrite_blocks,
60
+ default_type: (volatile ? "volatile" : "non-null")
61
+ end
55
62
  elsif default.is_a?(Proc) && postgresql?
56
63
  # adding a column with a VOLATILE default is not safe
57
64
  # https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES
@@ -25,6 +25,16 @@ class Backfill%{migration_name} < ActiveRecord::Migration%{migration_suffix}
25
25
  end
26
26
  end",
27
27
 
28
+ add_column_default_null:
29
+ "Adding a column with a null default blocks %{rewrite_blocks} while the entire table is rewritten.
30
+ Instead, add the column without a default value.
31
+
32
+ class %{migration_name} < ActiveRecord::Migration%{migration_suffix}
33
+ def change
34
+ %{command}
35
+ end
36
+ end",
37
+
28
38
  add_column_default_callable:
29
39
  "Strong Migrations does not support inspecting callable default values.
30
40
  Please make really sure you're not calling a VOLATILE function,
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
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.3.1
4
+ version: 1.3.2
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-09-21 00:00:00.000000000 Z
13
+ date: 2022-10-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord