strong_migrations 1.4.4 → 1.5.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -0
- data/lib/strong_migrations/checks.rb +5 -1
- data/lib/strong_migrations/error_messages.rb +3 -0
- data/lib/strong_migrations/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b830fe1881c2a85f578d28bb4b938c38204627897639cfc28ae44486f81dfb90
|
4
|
+
data.tar.gz: '09b4ef459fa407a8143120ec2dc19c98b5b02a885b1537cce26d63bea648eeab'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e34db2fb7db9d0b22c9c3c2a8ecca150308cb70b54e1e2b08eec2ccb52460f8aa9818a409aec0d7782678523bda35471fbd693cf4b025bbbd9dffe26a127afb
|
7
|
+
data.tar.gz: aad5de96c3886caa4c34f78a85edd6a8ada109f3acc31d8d72bcc6ff8d3ee41787f052cfcf56598103c30dddccd22a61d958e40ae6ac8bcdafeed22b4bc6d3c3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,7 @@ Potentially dangerous operations:
|
|
62
62
|
- [removing a column](#removing-a-column)
|
63
63
|
- [adding a column with a default value](#adding-a-column-with-a-default-value)
|
64
64
|
- [backfilling data](#backfilling-data)
|
65
|
+
- [adding a stored generated column](#adding-a-stored-generated-column) [unreleased]
|
65
66
|
- [changing the type of a column](#changing-the-type-of-a-column)
|
66
67
|
- [renaming a column](#renaming-a-column)
|
67
68
|
- [renaming a table](#renaming-a-table)
|
@@ -191,6 +192,24 @@ class BackfillSomeColumn < ActiveRecord::Migration[7.0]
|
|
191
192
|
end
|
192
193
|
```
|
193
194
|
|
195
|
+
### Adding a stored generated column
|
196
|
+
|
197
|
+
#### Bad
|
198
|
+
|
199
|
+
Adding a stored generated column causes the entire table to be rewritten. During this time, reads and writes are blocked in Postgres, and writes are blocked in MySQL and MariaDB.
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
class AddSomeColumnToUsers < ActiveRecord::Migration[7.0]
|
203
|
+
def change
|
204
|
+
add_column :users, :some_column, :virtual, type: :string, as: "...", stored: true
|
205
|
+
end
|
206
|
+
end
|
207
|
+
```
|
208
|
+
|
209
|
+
#### Good
|
210
|
+
|
211
|
+
Add a non-generated column and use callbacks or triggers instead (or a virtual generated column with MySQL and MariaDB).
|
212
|
+
|
194
213
|
### Changing the type of a column
|
195
214
|
|
196
215
|
#### Bad
|
@@ -71,6 +71,10 @@ Then add the NOT NULL constraint in separate migrations."
|
|
71
71
|
raise_error :add_column_json,
|
72
72
|
command: command_str("add_column", [table, column, :jsonb, options])
|
73
73
|
end
|
74
|
+
|
75
|
+
if type.to_s == "virtual" && options[:stored]
|
76
|
+
raise_error :add_column_generated_stored, rewrite_blocks: adapter.rewrite_blocks
|
77
|
+
end
|
74
78
|
end
|
75
79
|
|
76
80
|
def check_add_exclusion_constraint(*args)
|
@@ -147,7 +151,7 @@ Then add the NOT NULL constraint in separate migrations."
|
|
147
151
|
if bad_index || options[:foreign_key]
|
148
152
|
if index_value.is_a?(Hash)
|
149
153
|
options[:index] = options[:index].merge(algorithm: :concurrently)
|
150
|
-
|
154
|
+
elsif index_value
|
151
155
|
options = options.merge(index: {algorithm: :concurrently})
|
152
156
|
end
|
153
157
|
|
@@ -50,6 +50,9 @@ class %{migration_name} < ActiveRecord::Migration%{migration_suffix}
|
|
50
50
|
end
|
51
51
|
end",
|
52
52
|
|
53
|
+
add_column_generated_stored:
|
54
|
+
"Adding a stored generated column blocks %{rewrite_blocks} while the entire table is rewritten.",
|
55
|
+
|
53
56
|
change_column:
|
54
57
|
"Changing the type of an existing column blocks %{rewrite_blocks}
|
55
58
|
while the entire table is rewritten. A safer approach is to:
|
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.
|
4
|
+
version: 1.5.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: 2023-
|
13
|
+
date: 2023-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.4.
|
78
|
+
rubygems_version: 3.4.10
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Catch unsafe migrations in development
|