strong_migrations 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/strong_migrations/adapters/mysql_adapter.rb +24 -7
- 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: 8cfd384b72ffa6aa5ca1b7ed100ecfd9a7eb5f76f5ae1297454f123504629079
|
4
|
+
data.tar.gz: fc18dd031a7b25879ef769c4a96ef006778685d6203d2ae76ca2433c608a240f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc1870c87c77070f1ecc76347139e44295a236548f65619ad842e943977319e74517462cdddd62527b353a0a85f039968f26235463c99d5f50fedc75d062d1f
|
7
|
+
data.tar.gz: baec22cb082ffae658824bc9669dabd5141b8cc6a6502388c37e8e6ab85124eb10655731cb2ab3f520fc3864a580190e4c6a17ff422c1adc267d44f367ce9ab0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -224,7 +224,7 @@ And some in MySQL and MariaDB:
|
|
224
224
|
|
225
225
|
Type | Safe Changes
|
226
226
|
--- | ---
|
227
|
-
`string` | Increasing `:limit` from under
|
227
|
+
`string` | Increasing `:limit` from under 63 up to 63, increasing `:limit` from over 63 to the max (the threshold may be different if using an encoding other than `utf8mb4`)
|
228
228
|
|
229
229
|
#### Good
|
230
230
|
|
@@ -52,14 +52,31 @@ module StrongMigrations
|
|
52
52
|
|
53
53
|
case type.to_s
|
54
54
|
when "string"
|
55
|
-
# https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html
|
56
|
-
# https://mariadb.com/kb/en/innodb-online-ddl-operations-with-the-instant-alter-algorithm/#changing-the-data-type-of-a-column
|
57
|
-
# increased limit, but doesn't change number of length bytes
|
58
|
-
# 1-255 = 1 byte, 256-65532 = 2 bytes, 65533+ = too big for varchar
|
59
55
|
limit = options[:limit] || 255
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
if ["varchar"].include?(existing_type) && limit >= existing_column.limit
|
57
|
+
# https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html
|
58
|
+
# https://mariadb.com/kb/en/innodb-online-ddl-operations-with-the-instant-alter-algorithm/#changing-the-data-type-of-a-column
|
59
|
+
# increased limit, but doesn't change number of length bytes
|
60
|
+
# 1-255 = 1 byte, 256-65532 = 2 bytes, 65533+ = too big for varchar
|
61
|
+
|
62
|
+
# account for charset
|
63
|
+
# https://dev.mysql.com/doc/refman/8.0/en/charset-mysql.html
|
64
|
+
# https://mariadb.com/kb/en/supported-character-sets-and-collations/
|
65
|
+
sql = <<~SQL
|
66
|
+
SELECT cs.MAXLEN
|
67
|
+
FROM INFORMATION_SCHEMA.CHARACTER_SETS cs
|
68
|
+
INNER JOIN INFORMATION_SCHEMA.COLLATIONS c ON c.CHARACTER_SET_NAME = cs.CHARACTER_SET_NAME
|
69
|
+
INNER JOIN INFORMATION_SCHEMA.TABLES t ON t.TABLE_COLLATION = c.COLLATION_NAME
|
70
|
+
WHERE t.TABLE_SCHEMA = database() AND t.TABLE_NAME = #{connection.quote(table)}
|
71
|
+
SQL
|
72
|
+
row = connection.select_all(sql).first
|
73
|
+
if row
|
74
|
+
threshold = 255 / row["MAXLEN"]
|
75
|
+
safe = limit <= threshold || existing_column.limit > threshold
|
76
|
+
else
|
77
|
+
warn "[strong_migrations] Could not determine charset"
|
78
|
+
end
|
79
|
+
end
|
63
80
|
end
|
64
81
|
|
65
82
|
safe
|
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.
|
4
|
+
version: 1.4.3
|
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-02-19 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.6
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Catch unsafe migrations in development
|