declare_schema 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/declare_schema_build.yml +1 -12
- data/.ruby-version +1 -1
- data/Appraisals +0 -17
- data/CHANGELOG.md +4 -38
- data/Gemfile.lock +141 -129
- data/README.md +12 -0
- data/config/brakeman.ignore +71 -0
- data/lib/declare_schema/model/index_definition.rb +22 -6
- data/lib/declare_schema/version.rb +1 -1
- data/lib/declare_schema.rb +8 -1
- data/spec/lib/declare_schema/migration_generator_spec.rb +9 -9
- data/spec/lib/declare_schema/model/index_definition_spec.rb +74 -49
- data/spec/lib/declare_schema_spec.rb +44 -14
- metadata +4 -5
- data/gemfiles/rails_5_mysql.gemfile +0 -21
- data/gemfiles/rails_5_sqlite.gemfile +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51aba0260c648b9baab8e50a93ff384d4e8b2f39d6dd9284f9fbd900773f9207
|
4
|
+
data.tar.gz: 9cb9859880e62e726fc87b5e9d6893eabfc9ec102be35139a1a390fffba6a7ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3314c3544ffde59d7447dec0c64060355f4dd30ee659eae769029deb4f486df8347290c674ab368321a71be6072bada62a6217c60eaaade2780e2fda0c70e258
|
7
|
+
data.tar.gz: 5f1e040b3f8edaee24375e79cba08b4da33df9ec400a884dfe8f4445485723110ea85763456708d7cd59f28060a332f6800795ebfae71ea3cd53cf03ddaf0934
|
@@ -10,21 +10,10 @@ jobs:
|
|
10
10
|
strategy:
|
11
11
|
fail-fast: false
|
12
12
|
matrix:
|
13
|
-
ruby: [2.
|
13
|
+
ruby: [2.7, '3.0', 3.1, 3.2]
|
14
14
|
gemfile:
|
15
|
-
- gemfiles/rails_5_mysql.gemfile
|
16
|
-
- gemfiles/rails_5_sqlite.gemfile
|
17
15
|
- gemfiles/rails_6_mysql.gemfile
|
18
16
|
- gemfiles/rails_6_sqlite.gemfile
|
19
|
-
exclude:
|
20
|
-
- ruby: '3.0'
|
21
|
-
gemfile: gemfiles/rails_5_mysql.gemfile
|
22
|
-
- ruby: 3.1
|
23
|
-
gemfile: gemfiles/rails_5_mysql.gemfile
|
24
|
-
- ruby: '3.0'
|
25
|
-
gemfile: gemfiles/rails_5_sqlite.gemfile
|
26
|
-
- ruby: 3.1
|
27
|
-
gemfile: gemfiles/rails_5_sqlite.gemfile
|
28
17
|
|
29
18
|
env:
|
30
19
|
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.1
|
data/Appraisals
CHANGED
@@ -1,22 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'rails-5-sqlite' do
|
4
|
-
gem 'rails', '~> 5.2'
|
5
|
-
gem 'sqlite3'
|
6
|
-
|
7
|
-
remove_gem 'mail'
|
8
|
-
remove_gem 'net-smtp'
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise 'rails-5-mysql' do
|
12
|
-
gem 'rails', '~> 5.2'
|
13
|
-
gem 'mysql2'
|
14
|
-
|
15
|
-
remove_gem 'mail'
|
16
|
-
remove_gem 'net-smtp'
|
17
|
-
remove_gem 'sqlite3'
|
18
|
-
end
|
19
|
-
|
20
3
|
appraise 'rails-6-sqlite' do
|
21
4
|
gem 'rails', '~> 6.1'
|
22
5
|
gem 'sqlite3'
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.3.0] - 2023-07-10
|
8
|
+
### Added
|
9
|
+
- Added `DeclareSchema.max_index_and_constraint_name_length` with default of 64.
|
10
|
+
|
7
11
|
## [1.2.3] - 2023-04-04
|
8
12
|
### Changed
|
9
13
|
- Fixed a bug where renaming a foreign key resulted in an incorrect migration
|
@@ -256,41 +260,3 @@ using the appropriate Rails configuration attributes.
|
|
256
260
|
## [0.1.1] - 2020-09-24
|
257
261
|
### Added
|
258
262
|
- Initial version from https://github.com/Invoca/hobo_fields v4.1.0.
|
259
|
-
|
260
|
-
[1.2.1]: https://github.com/Invoca/declare_schema/compare/v1.2.0...v1.2.1
|
261
|
-
[1.2.0]: https://github.com/Invoca/declare_schema/compare/v1.1.0...v1.2.0
|
262
|
-
[1.1.0]: https://github.com/Invoca/declare_schema/compare/v1.0.2...v1.1.0
|
263
|
-
[1.0.2]: https://github.com/Invoca/declare_schema/compare/v1.0.1...v1.0.2
|
264
|
-
[1.0.1]: https://github.com/Invoca/declare_schema/compare/v1.0.0...v1.0.1
|
265
|
-
[1.0.0]: https://github.com/Invoca/declare_schema/compare/v0.14.3...v1.0.0
|
266
|
-
[0.14.3]: https://github.com/Invoca/declare_schema/compare/v0.14.2...v0.14.3
|
267
|
-
[0.14.2]: https://github.com/Invoca/declare_schema/compare/v0.14.1...v0.14.2
|
268
|
-
[0.14.1]: https://github.com/Invoca/declare_schema/compare/v0.14.0...v0.14.1
|
269
|
-
[0.14.0]: https://github.com/Invoca/declare_schema/compare/v0.13.1...v0.14.0
|
270
|
-
[0.13.1]: https://github.com/Invoca/declare_schema/compare/v0.13.0...v0.13.1
|
271
|
-
[0.13.0]: https://github.com/Invoca/declare_schema/compare/v0.12.1...v0.13.0
|
272
|
-
[0.12.1]: https://github.com/Invoca/declare_schema/compare/v0.12.0...v0.12.1
|
273
|
-
[0.12.0]: https://github.com/Invoca/declare_schema/compare/v0.11.1...v0.12.0
|
274
|
-
[0.11.1]: https://github.com/Invoca/declare_schema/compare/v0.11.0...v0.11.1
|
275
|
-
[0.11.0]: https://github.com/Invoca/declare_schema/compare/v0.10.1...v0.11.0
|
276
|
-
[0.10.1]: https://github.com/Invoca/declare_schema/compare/v0.10.0...v0.10.1
|
277
|
-
[0.10.0]: https://github.com/Invoca/declare_schema/compare/v0.9.0...v0.10.0
|
278
|
-
[0.9.0]: https://github.com/Invoca/declare_schema/compare/v0.8.0...v0.9.0
|
279
|
-
[0.8.0]: https://github.com/Invoca/declare_schema/compare/v0.7.1...v0.8.0
|
280
|
-
[0.7.1]: https://github.com/Invoca/declare_schema/compare/v0.7.0...v0.7.1
|
281
|
-
[0.7.0]: https://github.com/Invoca/declare_schema/compare/v0.6.3...v0.7.0
|
282
|
-
[0.6.4]: https://github.com/Invoca/declare_schema/compare/v0.6.3...v0.6.4
|
283
|
-
[0.6.3]: https://github.com/Invoca/declare_schema/compare/v0.6.2...v0.6.3
|
284
|
-
[0.6.2]: https://github.com/Invoca/declare_schema/compare/v0.6.1...v0.6.2
|
285
|
-
[0.6.1]: https://github.com/Invoca/declare_schema/compare/v0.6.0...v0.6.1
|
286
|
-
[0.6.0]: https://github.com/Invoca/declare_schema/compare/v0.5.0...v0.6.0
|
287
|
-
[0.5.0]: https://github.com/Invoca/declare_schema/compare/v0.4.2...v0.5.0
|
288
|
-
[0.4.2]: https://github.com/Invoca/declare_schema/compare/v0.4.1...v0.4.2
|
289
|
-
[0.4.1]: https://github.com/Invoca/declare_schema/compare/v0.4.0...v0.4.1
|
290
|
-
[0.4.0]: https://github.com/Invoca/declare_schema/compare/v0.3.1...v0.4.0
|
291
|
-
[0.3.1]: https://github.com/Invoca/declare_schema/compare/v0.3.0...v0.3.1
|
292
|
-
[0.3.0]: https://github.com/Invoca/declare_schema/compare/v0.2.0...v0.3.0
|
293
|
-
[0.2.0]: https://github.com/Invoca/declare_schema/compare/v0.1.3...v0.2.0
|
294
|
-
[0.1.3]: https://github.com/Invoca/declare_schema/compare/v0.1.2...v0.1.3
|
295
|
-
[0.1.2]: https://github.com/Invoca/declare_schema/compare/v0.1.1...v0.1.2
|
296
|
-
[0.1.1]: https://github.com/Invoca/declare_schema/tree/v0.1.1
|
data/Gemfile.lock
CHANGED
@@ -1,66 +1,66 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
declare_schema (1.
|
4
|
+
declare_schema (1.3.0)
|
5
5
|
rails (>= 5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (6.1.
|
11
|
-
actionpack (= 6.1.
|
12
|
-
activesupport (= 6.1.
|
10
|
+
actioncable (6.1.7.4)
|
11
|
+
actionpack (= 6.1.7.4)
|
12
|
+
activesupport (= 6.1.7.4)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.1.
|
16
|
-
actionpack (= 6.1.
|
17
|
-
activejob (= 6.1.
|
18
|
-
activerecord (= 6.1.
|
19
|
-
activestorage (= 6.1.
|
20
|
-
activesupport (= 6.1.
|
15
|
+
actionmailbox (6.1.7.4)
|
16
|
+
actionpack (= 6.1.7.4)
|
17
|
+
activejob (= 6.1.7.4)
|
18
|
+
activerecord (= 6.1.7.4)
|
19
|
+
activestorage (= 6.1.7.4)
|
20
|
+
activesupport (= 6.1.7.4)
|
21
21
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.1.
|
23
|
-
actionpack (= 6.1.
|
24
|
-
actionview (= 6.1.
|
25
|
-
activejob (= 6.1.
|
26
|
-
activesupport (= 6.1.
|
22
|
+
actionmailer (6.1.7.4)
|
23
|
+
actionpack (= 6.1.7.4)
|
24
|
+
actionview (= 6.1.7.4)
|
25
|
+
activejob (= 6.1.7.4)
|
26
|
+
activesupport (= 6.1.7.4)
|
27
27
|
mail (~> 2.5, >= 2.5.4)
|
28
28
|
rails-dom-testing (~> 2.0)
|
29
|
-
actionpack (6.1.
|
30
|
-
actionview (= 6.1.
|
31
|
-
activesupport (= 6.1.
|
29
|
+
actionpack (6.1.7.4)
|
30
|
+
actionview (= 6.1.7.4)
|
31
|
+
activesupport (= 6.1.7.4)
|
32
32
|
rack (~> 2.0, >= 2.0.9)
|
33
33
|
rack-test (>= 0.6.3)
|
34
34
|
rails-dom-testing (~> 2.0)
|
35
35
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
-
actiontext (6.1.
|
37
|
-
actionpack (= 6.1.
|
38
|
-
activerecord (= 6.1.
|
39
|
-
activestorage (= 6.1.
|
40
|
-
activesupport (= 6.1.
|
36
|
+
actiontext (6.1.7.4)
|
37
|
+
actionpack (= 6.1.7.4)
|
38
|
+
activerecord (= 6.1.7.4)
|
39
|
+
activestorage (= 6.1.7.4)
|
40
|
+
activesupport (= 6.1.7.4)
|
41
41
|
nokogiri (>= 1.8.5)
|
42
|
-
actionview (6.1.
|
43
|
-
activesupport (= 6.1.
|
42
|
+
actionview (6.1.7.4)
|
43
|
+
activesupport (= 6.1.7.4)
|
44
44
|
builder (~> 3.1)
|
45
45
|
erubi (~> 1.4)
|
46
46
|
rails-dom-testing (~> 2.0)
|
47
47
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
-
activejob (6.1.
|
49
|
-
activesupport (= 6.1.
|
48
|
+
activejob (6.1.7.4)
|
49
|
+
activesupport (= 6.1.7.4)
|
50
50
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.1.
|
52
|
-
activesupport (= 6.1.
|
53
|
-
activerecord (6.1.
|
54
|
-
activemodel (= 6.1.
|
55
|
-
activesupport (= 6.1.
|
56
|
-
activestorage (6.1.
|
57
|
-
actionpack (= 6.1.
|
58
|
-
activejob (= 6.1.
|
59
|
-
activerecord (= 6.1.
|
60
|
-
activesupport (= 6.1.
|
51
|
+
activemodel (6.1.7.4)
|
52
|
+
activesupport (= 6.1.7.4)
|
53
|
+
activerecord (6.1.7.4)
|
54
|
+
activemodel (= 6.1.7.4)
|
55
|
+
activesupport (= 6.1.7.4)
|
56
|
+
activestorage (6.1.7.4)
|
57
|
+
actionpack (= 6.1.7.4)
|
58
|
+
activejob (= 6.1.7.4)
|
59
|
+
activerecord (= 6.1.7.4)
|
60
|
+
activesupport (= 6.1.7.4)
|
61
61
|
marcel (~> 1.0)
|
62
62
|
mini_mime (>= 1.1.0)
|
63
|
-
activesupport (6.1.
|
63
|
+
activesupport (6.1.7.4)
|
64
64
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
65
|
i18n (>= 1.6, < 2)
|
66
66
|
minitest (>= 5.1)
|
@@ -70,141 +70,153 @@ GEM
|
|
70
70
|
bundler
|
71
71
|
rake
|
72
72
|
thor (>= 0.14.0)
|
73
|
-
ast (2.4.
|
74
|
-
bootsnap (1.
|
75
|
-
msgpack (~> 1.
|
73
|
+
ast (2.4.2)
|
74
|
+
bootsnap (1.16.0)
|
75
|
+
msgpack (~> 1.2)
|
76
76
|
builder (3.2.4)
|
77
77
|
byebug (11.1.3)
|
78
78
|
climate_control (0.2.0)
|
79
79
|
coderay (1.1.3)
|
80
|
-
concurrent-ruby (1.
|
80
|
+
concurrent-ruby (1.2.2)
|
81
81
|
crass (1.0.6)
|
82
|
-
|
83
|
-
|
84
|
-
erubi (1.
|
85
|
-
ffi (1.15.
|
86
|
-
globalid (1.
|
82
|
+
date (3.3.3)
|
83
|
+
diff-lcs (1.5.0)
|
84
|
+
erubi (1.12.0)
|
85
|
+
ffi (1.15.5)
|
86
|
+
globalid (1.1.0)
|
87
87
|
activesupport (>= 5.0)
|
88
|
-
i18n (1.
|
88
|
+
i18n (1.14.1)
|
89
89
|
concurrent-ruby (~> 1.0)
|
90
|
-
|
91
|
-
|
90
|
+
json (2.6.3)
|
91
|
+
language_server-protocol (3.17.0.3)
|
92
|
+
listen (3.8.0)
|
92
93
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
93
94
|
rb-inotify (~> 0.9, >= 0.9.10)
|
94
|
-
loofah (2.
|
95
|
+
loofah (2.21.3)
|
95
96
|
crass (~> 1.0.2)
|
96
|
-
nokogiri (>= 1.
|
97
|
-
mail (2.
|
97
|
+
nokogiri (>= 1.12.0)
|
98
|
+
mail (2.8.1)
|
98
99
|
mini_mime (>= 0.1.1)
|
100
|
+
net-imap
|
101
|
+
net-pop
|
102
|
+
net-smtp
|
99
103
|
marcel (1.0.2)
|
100
104
|
method_source (1.0.0)
|
101
105
|
mini_mime (1.1.2)
|
102
|
-
mini_portile2 (2.8.
|
103
|
-
minitest (5.
|
104
|
-
msgpack (1.
|
105
|
-
net-
|
106
|
-
|
107
|
-
|
108
|
-
net-
|
109
|
-
digest
|
106
|
+
mini_portile2 (2.8.2)
|
107
|
+
minitest (5.18.1)
|
108
|
+
msgpack (1.7.1)
|
109
|
+
net-imap (0.3.6)
|
110
|
+
date
|
111
|
+
net-protocol
|
112
|
+
net-pop (0.1.2)
|
110
113
|
net-protocol
|
114
|
+
net-protocol (0.2.1)
|
111
115
|
timeout
|
112
|
-
|
113
|
-
|
114
|
-
|
116
|
+
net-smtp (0.3.3)
|
117
|
+
net-protocol
|
118
|
+
nio4r (2.5.9)
|
119
|
+
nokogiri (1.15.2)
|
120
|
+
mini_portile2 (~> 2.8.2)
|
115
121
|
racc (~> 1.4)
|
116
|
-
parallel (1.
|
117
|
-
parser (2.
|
122
|
+
parallel (1.23.0)
|
123
|
+
parser (3.2.2.3)
|
118
124
|
ast (~> 2.4.1)
|
119
|
-
|
125
|
+
racc
|
126
|
+
pry (0.14.2)
|
120
127
|
coderay (~> 1.1)
|
121
128
|
method_source (~> 1.0)
|
122
|
-
pry-byebug (3.
|
129
|
+
pry-byebug (3.10.1)
|
123
130
|
byebug (~> 11.0)
|
124
|
-
pry (
|
125
|
-
racc (1.
|
126
|
-
rack (2.2.
|
127
|
-
rack-test (
|
128
|
-
rack (>= 1.
|
129
|
-
rails (6.1.
|
130
|
-
actioncable (= 6.1.
|
131
|
-
actionmailbox (= 6.1.
|
132
|
-
actionmailer (= 6.1.
|
133
|
-
actionpack (= 6.1.
|
134
|
-
actiontext (= 6.1.
|
135
|
-
actionview (= 6.1.
|
136
|
-
activejob (= 6.1.
|
137
|
-
activemodel (= 6.1.
|
138
|
-
activerecord (= 6.1.
|
139
|
-
activestorage (= 6.1.
|
140
|
-
activesupport (= 6.1.
|
131
|
+
pry (>= 0.13, < 0.15)
|
132
|
+
racc (1.7.1)
|
133
|
+
rack (2.2.7)
|
134
|
+
rack-test (2.1.0)
|
135
|
+
rack (>= 1.3)
|
136
|
+
rails (6.1.7.4)
|
137
|
+
actioncable (= 6.1.7.4)
|
138
|
+
actionmailbox (= 6.1.7.4)
|
139
|
+
actionmailer (= 6.1.7.4)
|
140
|
+
actionpack (= 6.1.7.4)
|
141
|
+
actiontext (= 6.1.7.4)
|
142
|
+
actionview (= 6.1.7.4)
|
143
|
+
activejob (= 6.1.7.4)
|
144
|
+
activemodel (= 6.1.7.4)
|
145
|
+
activerecord (= 6.1.7.4)
|
146
|
+
activestorage (= 6.1.7.4)
|
147
|
+
activesupport (= 6.1.7.4)
|
141
148
|
bundler (>= 1.15.0)
|
142
|
-
railties (= 6.1.
|
149
|
+
railties (= 6.1.7.4)
|
143
150
|
sprockets-rails (>= 2.0.0)
|
144
|
-
rails-dom-testing (2.
|
145
|
-
activesupport (>=
|
151
|
+
rails-dom-testing (2.1.1)
|
152
|
+
activesupport (>= 5.0.0)
|
153
|
+
minitest
|
146
154
|
nokogiri (>= 1.6)
|
147
|
-
rails-html-sanitizer (1.
|
148
|
-
loofah (~> 2.
|
149
|
-
|
150
|
-
|
151
|
-
|
155
|
+
rails-html-sanitizer (1.6.0)
|
156
|
+
loofah (~> 2.21)
|
157
|
+
nokogiri (~> 1.14)
|
158
|
+
railties (6.1.7.4)
|
159
|
+
actionpack (= 6.1.7.4)
|
160
|
+
activesupport (= 6.1.7.4)
|
152
161
|
method_source
|
153
162
|
rake (>= 12.2)
|
154
163
|
thor (~> 1.0)
|
155
|
-
rainbow (3.
|
164
|
+
rainbow (3.1.1)
|
156
165
|
rake (13.0.6)
|
157
|
-
rb-fsevent (0.11.
|
166
|
+
rb-fsevent (0.11.2)
|
158
167
|
rb-inotify (0.10.1)
|
159
168
|
ffi (~> 1.0)
|
160
|
-
regexp_parser (
|
161
|
-
responders (3.0
|
162
|
-
actionpack (>= 5.
|
163
|
-
railties (>= 5.
|
164
|
-
rexml (3.2.
|
165
|
-
rspec (3.
|
166
|
-
rspec-core (~> 3.
|
167
|
-
rspec-expectations (~> 3.
|
168
|
-
rspec-mocks (~> 3.
|
169
|
-
rspec-core (3.
|
170
|
-
rspec-support (~> 3.
|
171
|
-
rspec-expectations (3.
|
169
|
+
regexp_parser (2.8.1)
|
170
|
+
responders (3.1.0)
|
171
|
+
actionpack (>= 5.2)
|
172
|
+
railties (>= 5.2)
|
173
|
+
rexml (3.2.5)
|
174
|
+
rspec (3.12.0)
|
175
|
+
rspec-core (~> 3.12.0)
|
176
|
+
rspec-expectations (~> 3.12.0)
|
177
|
+
rspec-mocks (~> 3.12.0)
|
178
|
+
rspec-core (3.12.2)
|
179
|
+
rspec-support (~> 3.12.0)
|
180
|
+
rspec-expectations (3.12.3)
|
172
181
|
diff-lcs (>= 1.2.0, < 2.0)
|
173
|
-
rspec-support (~> 3.
|
174
|
-
rspec-mocks (3.
|
182
|
+
rspec-support (~> 3.12.0)
|
183
|
+
rspec-mocks (3.12.5)
|
175
184
|
diff-lcs (>= 1.2.0, < 2.0)
|
176
|
-
rspec-support (~> 3.
|
177
|
-
rspec-support (3.
|
178
|
-
rubocop (
|
185
|
+
rspec-support (~> 3.12.0)
|
186
|
+
rspec-support (3.12.1)
|
187
|
+
rubocop (1.54.0)
|
188
|
+
json (~> 2.3)
|
189
|
+
language_server-protocol (>= 3.17.0)
|
179
190
|
parallel (~> 1.10)
|
180
|
-
parser (>= 2.
|
191
|
+
parser (>= 3.2.2.3)
|
181
192
|
rainbow (>= 2.2.2, < 4.0)
|
182
|
-
regexp_parser (>= 1.
|
183
|
-
rexml
|
184
|
-
rubocop-ast (>=
|
193
|
+
regexp_parser (>= 1.8, < 3.0)
|
194
|
+
rexml (>= 3.2.5, < 4.0)
|
195
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
185
196
|
ruby-progressbar (~> 1.7)
|
186
|
-
unicode-display_width (>=
|
187
|
-
rubocop-ast (
|
188
|
-
parser (>= 2.
|
189
|
-
ruby-progressbar (1.
|
190
|
-
sprockets (4.0
|
197
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
198
|
+
rubocop-ast (1.29.0)
|
199
|
+
parser (>= 3.2.1.0)
|
200
|
+
ruby-progressbar (1.13.0)
|
201
|
+
sprockets (4.2.0)
|
191
202
|
concurrent-ruby (~> 1.0)
|
192
|
-
rack (
|
203
|
+
rack (>= 2.2.4, < 4)
|
193
204
|
sprockets-rails (3.4.2)
|
194
205
|
actionpack (>= 5.2)
|
195
206
|
activesupport (>= 5.2)
|
196
207
|
sprockets (>= 3.0.0)
|
197
|
-
sqlite3 (1.
|
198
|
-
|
199
|
-
|
200
|
-
|
208
|
+
sqlite3 (1.6.3)
|
209
|
+
mini_portile2 (~> 2.8.0)
|
210
|
+
thor (1.2.2)
|
211
|
+
timeout (0.4.0)
|
212
|
+
tzinfo (2.0.6)
|
201
213
|
concurrent-ruby (~> 1.0)
|
202
|
-
unicode-display_width (
|
214
|
+
unicode-display_width (2.4.2)
|
203
215
|
websocket-driver (0.7.5)
|
204
216
|
websocket-extensions (>= 0.1.0)
|
205
217
|
websocket-extensions (0.1.5)
|
206
|
-
yard (0.9.
|
207
|
-
zeitwerk (2.
|
218
|
+
yard (0.9.34)
|
219
|
+
zeitwerk (2.6.8)
|
208
220
|
|
209
221
|
PLATFORMS
|
210
222
|
ruby
|
data/README.md
CHANGED
@@ -258,6 +258,18 @@ For example:
|
|
258
258
|
]
|
259
259
|
```
|
260
260
|
|
261
|
+
## Maximum Length of Index and Constraint Names
|
262
|
+
|
263
|
+
MySQL limits the length of index and constraint names to 64 characters.
|
264
|
+
Because the migrations generated by `DecleareSchema` are intended to be portable to any database type that
|
265
|
+
ActiveRecord supports, `DeclareSchema` will generate names that do not exceed the
|
266
|
+
configurable value:
|
267
|
+
```ruby
|
268
|
+
DeclareSchema.max_index_and_constraint_name_length = 64
|
269
|
+
```
|
270
|
+
If you know that your migrations will only be used on a database type with a different limit, you can
|
271
|
+
adjust this configuration value. A `nil` value means "unlimited".
|
272
|
+
|
261
273
|
## Declaring Character Set and Collation
|
262
274
|
_Note: This feature currently only works for MySQL database configurations._
|
263
275
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
{
|
2
|
+
"ignored_warnings": [
|
3
|
+
{
|
4
|
+
"warning_type": "Command Injection",
|
5
|
+
"warning_code": 14,
|
6
|
+
"fingerprint": "43f4448f6da2dd7f73909a4456c73c52f8f1d65e83bc188b9b3d624ba9470766",
|
7
|
+
"check_name": "Execute",
|
8
|
+
"message": "Possible command injection",
|
9
|
+
"file": "lib/declare_schema/command.rb",
|
10
|
+
"line": 61,
|
11
|
+
"link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
|
12
|
+
"code": "system(\"bundle exec rails #{Regexp.last_match(1)} declare_schema:#{(args * \" \")}\")",
|
13
|
+
"render_path": null,
|
14
|
+
"location": {
|
15
|
+
"type": "method",
|
16
|
+
"class": "DeclareSchema::Command",
|
17
|
+
"method": "run"
|
18
|
+
},
|
19
|
+
"user_input": "Regexp.last_match(1)",
|
20
|
+
"confidence": "Medium",
|
21
|
+
"cwe_id": [
|
22
|
+
77
|
23
|
+
],
|
24
|
+
"note": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"warning_type": "Command Injection",
|
28
|
+
"warning_code": 14,
|
29
|
+
"fingerprint": "601f18b634f67229235d6e91434d1ea4c3c845876c4786d27380034e66178ee6",
|
30
|
+
"check_name": "Execute",
|
31
|
+
"message": "Possible command injection",
|
32
|
+
"file": "lib/declare_schema/command.rb",
|
33
|
+
"line": 51,
|
34
|
+
"link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
|
35
|
+
"code": "system(\"rails new #{\"new\"} #{(args * \" \")} -m #{File.join(Dir.tmpdir, \"declare_schema_app_template\")}#{begin\n (require(\"mysql2\")\n \" -d mysql\")\nrescue LoadError\n # do nothing\nend}\")",
|
36
|
+
"render_path": null,
|
37
|
+
"location": {
|
38
|
+
"type": "method",
|
39
|
+
"class": "DeclareSchema::Command",
|
40
|
+
"method": "run"
|
41
|
+
},
|
42
|
+
"user_input": "(args * \" \")",
|
43
|
+
"confidence": "Medium",
|
44
|
+
"cwe_id": [
|
45
|
+
77
|
46
|
+
],
|
47
|
+
"note": ""
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"warning_type": "Unmaintained Dependency",
|
51
|
+
"warning_code": 121,
|
52
|
+
"fingerprint": "edf687f759ec9765bd5db185dbc615c80af77d6e7e19386fc42934e7a80307af",
|
53
|
+
"check_name": "EOLRuby",
|
54
|
+
"message": "Support for Ruby 2.7.5 ended on 2023-03-31",
|
55
|
+
"file": ".ruby-version",
|
56
|
+
"line": 1,
|
57
|
+
"link": "https://brakemanscanner.org/docs/warning_types/unmaintained_dependency/",
|
58
|
+
"code": null,
|
59
|
+
"render_path": null,
|
60
|
+
"location": null,
|
61
|
+
"user_input": null,
|
62
|
+
"confidence": "High",
|
63
|
+
"cwe_id": [
|
64
|
+
1104
|
65
|
+
],
|
66
|
+
"note": ""
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"updated": "2023-07-02 21:29:31 -0700",
|
70
|
+
"brakeman_version": "5.4.1"
|
71
|
+
}
|
@@ -12,18 +12,17 @@ module DeclareSchema
|
|
12
12
|
class IndexNameTooLongError < RuntimeError; end
|
13
13
|
|
14
14
|
PRIMARY_KEY_NAME = "PRIMARY"
|
15
|
-
MYSQL_INDEX_NAME_MAX_LENGTH = 64
|
16
15
|
|
17
16
|
def initialize(model, fields, **options)
|
18
17
|
@model = model
|
19
18
|
@table = options.delete(:table_name) || model.table_name
|
20
19
|
@fields = Array.wrap(fields).map(&:to_s)
|
21
20
|
@explicit_name = options[:name] unless options.delete(:allow_equivalent)
|
22
|
-
@name = options.delete(:name) || self.class.default_index_name(@fields)
|
21
|
+
@name = options.delete(:name) || self.class.default_index_name(@table, @fields)
|
23
22
|
@unique = options.delete(:unique) || name == PRIMARY_KEY_NAME || false
|
24
23
|
|
25
|
-
if @name.length >
|
26
|
-
raise IndexNameTooLongError, "Index '#{@name}' exceeds
|
24
|
+
if DeclareSchema.max_index_and_constraint_name_length && @name.length > DeclareSchema.max_index_and_constraint_name_length
|
25
|
+
raise IndexNameTooLongError, "Index '#{@name}' exceeds configured limit of #{DeclareSchema.max_index_and_constraint_name_length} characters. Give it a shorter name, or adjust DeclareSchema.max_index_and_constraint_name_length if you know your database can accept longer names."
|
27
26
|
end
|
28
27
|
|
29
28
|
if (where = options[:where])
|
@@ -57,8 +56,25 @@ module DeclareSchema
|
|
57
56
|
index_definitions
|
58
57
|
end
|
59
58
|
|
60
|
-
def default_index_name(
|
61
|
-
|
59
|
+
def default_index_name(table, fields)
|
60
|
+
index_name = nil
|
61
|
+
[:long_index_name, :short_index_name].find do |method_name|
|
62
|
+
index_name = send(method_name, table, fields)
|
63
|
+
if DeclareSchema.max_index_and_constraint_name_length.nil? || index_name.length <= DeclareSchema.max_index_and_constraint_name_length
|
64
|
+
break index_name
|
65
|
+
end
|
66
|
+
end or raise IndexNameTooLongError,
|
67
|
+
"Index '#{index_name}' exceeds configured limit of #{DeclareSchema.max_index_and_constraint_name_length} characters."
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def long_index_name(table_name, columns)
|
73
|
+
"index_#{table_name}_on_#{Array(columns).join("_and_")}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def short_index_name(table_name, columns)
|
77
|
+
"#{table_name}__#{Array(columns).join("_")}"
|
62
78
|
end
|
63
79
|
end
|
64
80
|
|
data/lib/declare_schema.rb
CHANGED
@@ -29,10 +29,12 @@ module DeclareSchema
|
|
29
29
|
@default_generate_foreign_keys = true
|
30
30
|
@default_generate_indexing = true
|
31
31
|
@db_migrate_command = "bundle exec rails db:migrate"
|
32
|
+
@max_index_and_constraint_name_length = 64 # limit for MySQL
|
32
33
|
|
33
34
|
class << self
|
34
35
|
attr_reader :default_charset, :default_collation, :default_text_limit, :default_string_limit, :default_null,
|
35
|
-
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
|
36
|
+
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command,
|
37
|
+
:max_index_and_constraint_name_length
|
36
38
|
|
37
39
|
def to_class(type)
|
38
40
|
case type
|
@@ -97,6 +99,11 @@ module DeclareSchema
|
|
97
99
|
db_migrate_command.is_a?(String) or raise ArgumentError, "db_migrate_command must be a string (got #{db_migrate_command.inspect})"
|
98
100
|
@db_migrate_command = db_migrate_command
|
99
101
|
end
|
102
|
+
|
103
|
+
def max_index_and_constraint_name_length=(length)
|
104
|
+
length.is_a?(Integer) || length.nil? or raise ArgumentError, "max_index_and_constraint_name_length must be an Integer or nil (meaning unlimited)"
|
105
|
+
@max_index_and_constraint_name_length = length
|
106
|
+
end
|
100
107
|
end
|
101
108
|
end
|
102
109
|
|
@@ -359,12 +359,12 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
359
359
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
360
360
|
migrate_up(<<~EOS.strip)
|
361
361
|
add_column :adverts, :category_id, :integer, limit: 8, null: false
|
362
|
-
add_index :adverts, [:category_id], name: :
|
362
|
+
add_index :adverts, [:category_id], name: :index_adverts_on_category_id
|
363
363
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" if defined?(Mysql2)}
|
364
364
|
EOS
|
365
365
|
.and migrate_down(<<~EOS.strip)
|
366
366
|
#{"remove_foreign_key :adverts, name: :index_adverts_on_category_id" if defined?(Mysql2)}
|
367
|
-
remove_index :adverts, name: :
|
367
|
+
remove_index :adverts, name: :index_adverts_on_category_id
|
368
368
|
remove_column :adverts, :category_id
|
369
369
|
EOS
|
370
370
|
)
|
@@ -383,7 +383,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
383
383
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
384
384
|
migrate_up(<<~EOS.strip)
|
385
385
|
add_column :adverts, :c_id, :integer, limit: 8, null: false
|
386
|
-
add_index :adverts, [:c_id], name: :
|
386
|
+
add_index :adverts, [:c_id], name: :index_adverts_on_c_id
|
387
387
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" +
|
388
388
|
"add_foreign_key :adverts, :categories, column: :c_id, name: :index_adverts_on_c_id" if defined?(Mysql2)}
|
389
389
|
EOS
|
@@ -477,7 +477,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
477
477
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
478
478
|
migrate_up(<<~EOS.strip)
|
479
479
|
add_column :adverts, :title, :string, limit: 250, null: true#{charset_and_collation}
|
480
|
-
add_index :adverts, [:title], name: :
|
480
|
+
add_index :adverts, [:title], name: :index_adverts_on_title
|
481
481
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" +
|
482
482
|
"add_foreign_key :adverts, :categories, column: :c_id, name: :index_adverts_on_c_id" if defined?(Mysql2)}
|
483
483
|
EOS
|
@@ -496,7 +496,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
496
496
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
497
497
|
migrate_up(<<~EOS.strip)
|
498
498
|
add_column :adverts, :title, :string, limit: 250, null: true#{charset_and_collation}
|
499
|
-
add_index :adverts, [:title], name: :
|
499
|
+
add_index :adverts, [:title], name: :index_adverts_on_title, unique: true
|
500
500
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" +
|
501
501
|
"add_foreign_key :adverts, :categories, column: :c_id, name: :index_adverts_on_c_id" if defined?(Mysql2)}
|
502
502
|
EOS
|
@@ -532,7 +532,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
532
532
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
533
533
|
migrate_up(<<~EOS.strip)
|
534
534
|
add_column :adverts, :title, :string, limit: 250, null: true#{charset_and_collation}
|
535
|
-
add_index :adverts, [:title], name: :
|
535
|
+
add_index :adverts, [:title], name: :index_adverts_on_title
|
536
536
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" +
|
537
537
|
"add_foreign_key :adverts, :categories, column: :c_id, name: :index_adverts_on_c_id" if defined?(Mysql2)}
|
538
538
|
EOS
|
@@ -566,7 +566,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
566
566
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to(
|
567
567
|
migrate_up(<<~EOS.strip)
|
568
568
|
add_column :adverts, :title, :string, limit: 250, null: true#{charset_and_collation}
|
569
|
-
add_index :adverts, [:title, :category_id], name: :
|
569
|
+
add_index :adverts, [:title, :category_id], name: :index_adverts_on_title_and_category_id
|
570
570
|
#{"add_foreign_key :adverts, :categories, column: :category_id, name: :index_adverts_on_category_id\n" +
|
571
571
|
"add_foreign_key :adverts, :categories, column: :c_id, name: :index_adverts_on_c_id" if defined?(Mysql2)}
|
572
572
|
EOS
|
@@ -866,8 +866,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
866
866
|
t.string :name, limit: 250, null: true, charset: "utf8mb4", collation: "utf8mb4_bin"
|
867
867
|
t.integer :category_id, limit: 8, null: false
|
868
868
|
end
|
869
|
-
add_index :advertisers, [:category_id], name: :
|
870
|
-
add_index :affiliates, [:category_id], name: :
|
869
|
+
add_index :advertisers, [:category_id], name: :index_advertisers_on_category_id
|
870
|
+
add_index :affiliates, [:category_id], name: :index_affiliates_on_category_id
|
871
871
|
add_foreign_key :advertisers, :categories, column: :category_id, name: :index_advertisers_on_category_id
|
872
872
|
add_foreign_key :affiliates, :categories, column: :category_id, name: :index_affiliates_on_category_id
|
873
873
|
EOS
|
@@ -40,75 +40,100 @@ RSpec.describe DeclareSchema::Model::IndexDefinition do
|
|
40
40
|
|
41
41
|
it 'has index_definitions' do
|
42
42
|
expect(model_class.index_definitions).to be_kind_of(Array)
|
43
|
-
expect(model_class.index_definitions.map(&:name)).to eq(['
|
43
|
+
expect(model_class.index_definitions.map(&:name)).to eq(['index_index_definition_test_models_on_name'])
|
44
44
|
expect([:name, :fields, :unique].map { |attr| model_class.index_definitions[0].send(attr)}).to eq(
|
45
|
-
|
46
|
-
|
45
|
+
['index_index_definition_test_models_on_name', ['name'], false]
|
46
|
+
)
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'has index_definitions_with_primary_key' do
|
50
50
|
expect(model_class.index_definitions_with_primary_key).to be_kind_of(Array)
|
51
51
|
result = model_class.index_definitions_with_primary_key.sort_by(&:name)
|
52
|
-
expect(result.map(&:name)).to eq(['PRIMARY', '
|
52
|
+
expect(result.map(&:name)).to eq(['PRIMARY', 'index_index_definition_test_models_on_name'])
|
53
53
|
expect([:name, :fields, :unique].map { |attr| result[0].send(attr)}).to eq(
|
54
|
-
|
55
|
-
|
54
|
+
['PRIMARY', ['id'], true]
|
55
|
+
)
|
56
56
|
expect([:name, :fields, :unique].map { |attr| result[1].send(attr)}).to eq(
|
57
|
-
|
58
|
-
|
57
|
+
['index_index_definition_test_models_on_name', ['name'], false]
|
58
|
+
)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
ActiveRecord::Base.connection.execute <<~EOS
|
62
|
+
context 'with a migrated database' do
|
63
|
+
before do
|
64
|
+
ActiveRecord::Base.connection.execute <<~EOS
|
65
|
+
CREATE TABLE index_definition_test_models (
|
66
|
+
id INTEGER NOT NULL PRIMARY KEY,
|
67
|
+
name #{if defined?(SQLite3) then 'TEXT' else 'VARCHAR(255)' end} NOT NULL
|
68
|
+
)
|
69
|
+
EOS
|
70
|
+
ActiveRecord::Base.connection.execute <<~EOS
|
72
71
|
CREATE UNIQUE INDEX index_definition_test_models_on_name ON index_definition_test_models(name)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
EOS
|
73
|
+
ActiveRecord::Base.connection.execute <<~EOS
|
74
|
+
CREATE TABLE index_definition_compound_index_models (
|
75
|
+
fk1_id INTEGER NOT NULL,
|
76
|
+
fk2_id INTEGER NOT NULL,
|
77
|
+
PRIMARY KEY (fk1_id, fk2_id)
|
78
|
+
)
|
79
|
+
EOS
|
80
|
+
ActiveRecord::Base.connection.schema_cache.clear!
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'for_model' do
|
84
|
+
subject { described_class.for_model(model_class) }
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
expect([:name, :columns, :unique].map { |attr| subject[1].send(attr) }).to eq(
|
94
|
-
['PRIMARY', ['id'], true]
|
95
|
-
)
|
96
|
-
end
|
86
|
+
context 'with single-column PK' do
|
87
|
+
it 'returns the indexes for the model' do
|
88
|
+
expect(subject.size).to eq(2), subject.inspect
|
89
|
+
expect([:name, :columns, :unique].map { |attr| subject[0].send(attr) }).to eq(
|
90
|
+
['index_definition_test_models_on_name', ['name'], true]
|
91
|
+
)
|
92
|
+
expect([:name, :columns, :unique].map { |attr| subject[1].send(attr) }).to eq(
|
93
|
+
['PRIMARY', ['id'], true]
|
94
|
+
)
|
97
95
|
end
|
96
|
+
end
|
98
97
|
|
99
|
-
|
100
|
-
|
98
|
+
context 'with compound-column PK' do
|
99
|
+
let(:model_class) { IndexDefinitionCompoundIndexModel }
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
101
|
+
it 'returns the indexes for the model' do
|
102
|
+
expect(subject.size).to eq(1), subject.inspect
|
103
|
+
expect([:name, :columns, :unique].map { |attr| subject[0].send(attr) }).to eq(
|
104
|
+
['PRIMARY', ['fk1_id', 'fk2_id'], true]
|
105
|
+
)
|
108
106
|
end
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
112
110
|
end
|
111
|
+
|
112
|
+
context 'with no side effects' do
|
113
|
+
describe '.default_index_name' do
|
114
|
+
let(:table_name2) { 'users' }
|
115
|
+
let(:columns2) { ['last_name', 'first_name', 'middle_name', ] }
|
116
|
+
subject { described_class.default_index_name(table_name2, columns2) }
|
117
|
+
around do |spec|
|
118
|
+
orig_value = DeclareSchema.max_index_and_constraint_name_length
|
119
|
+
DeclareSchema.max_index_and_constraint_name_length = max_index_and_constraint_name_length
|
120
|
+
spec.run
|
121
|
+
ensure
|
122
|
+
DeclareSchema.max_index_and_constraint_name_length = orig_value
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with unlimited max_index_and_constraint_name_length' do
|
126
|
+
let(:max_index_and_constraint_name_length) { nil }
|
127
|
+
|
128
|
+
it { is_expected.to eq("index_users_on_last_name_and_first_name_and_middle_name") }
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with short max_index_and_constraint_name_length' do
|
132
|
+
let(:max_index_and_constraint_name_length) { 40 }
|
133
|
+
|
134
|
+
it { is_expected.to eq("users__last_name_first_name_middle_name") }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
113
138
|
# TODO: fill out remaining tests
|
114
139
|
end
|
@@ -5,13 +5,13 @@ RSpec.describe DeclareSchema do
|
|
5
5
|
subject { described_class.default_charset }
|
6
6
|
|
7
7
|
context 'when not explicitly set' do
|
8
|
-
it {
|
8
|
+
it { is_expected.to eq("utf8mb4") }
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'when explicitly set' do
|
12
12
|
before { described_class.default_charset = "utf8" }
|
13
13
|
after { described_class.default_charset = "utf8mb4" }
|
14
|
-
it {
|
14
|
+
it { is_expected.to eq("utf8") }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,13 +19,13 @@ RSpec.describe DeclareSchema do
|
|
19
19
|
subject { described_class.default_collation }
|
20
20
|
|
21
21
|
context 'when not explicitly set' do
|
22
|
-
it {
|
22
|
+
it { is_expected.to eq("utf8mb4_bin") }
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'when explicitly set' do
|
26
26
|
before { described_class.default_collation = "utf8mb4_general_ci" }
|
27
27
|
after { described_class.default_collation = "utf8mb4_bin" }
|
28
|
-
it {
|
28
|
+
it { is_expected.to eq("utf8mb4_general_ci") }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,13 +33,13 @@ RSpec.describe DeclareSchema do
|
|
33
33
|
subject { described_class.default_text_limit }
|
34
34
|
|
35
35
|
context 'when not explicitly set' do
|
36
|
-
it {
|
36
|
+
it { is_expected.to eq(0xffff_ffff) }
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'when explicitly set' do
|
40
40
|
before { described_class.default_text_limit = 0xffff }
|
41
41
|
after { described_class.default_text_limit = 0xffff_ffff }
|
42
|
-
it {
|
42
|
+
it { is_expected.to eq(0xffff) }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -47,13 +47,13 @@ RSpec.describe DeclareSchema do
|
|
47
47
|
subject { described_class.default_string_limit }
|
48
48
|
|
49
49
|
context 'when not explicitly set' do
|
50
|
-
it {
|
50
|
+
it { is_expected.to eq(nil) }
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'when explicitly set' do
|
54
54
|
before { described_class.default_string_limit = 225 }
|
55
55
|
after { described_class.default_string_limit = nil }
|
56
|
-
it {
|
56
|
+
it { is_expected.to eq(225) }
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -61,13 +61,13 @@ RSpec.describe DeclareSchema do
|
|
61
61
|
subject { described_class.default_null }
|
62
62
|
|
63
63
|
context 'when not explicitly set' do
|
64
|
-
it {
|
64
|
+
it { is_expected.to eq(false) }
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'when explicitly set' do
|
68
68
|
before { described_class.default_null = true }
|
69
69
|
after { described_class.default_null = false }
|
70
|
-
it {
|
70
|
+
it { is_expected.to eq(true) }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -75,13 +75,13 @@ RSpec.describe DeclareSchema do
|
|
75
75
|
subject { described_class.default_generate_foreign_keys }
|
76
76
|
|
77
77
|
context 'when not explicitly set' do
|
78
|
-
it {
|
78
|
+
it { is_expected.to eq(true) }
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'when explicitly set' do
|
82
82
|
before { described_class.default_generate_foreign_keys = false }
|
83
83
|
after { described_class.default_generate_foreign_keys = true }
|
84
|
-
it {
|
84
|
+
it { is_expected.to eq(false) }
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -89,13 +89,43 @@ RSpec.describe DeclareSchema do
|
|
89
89
|
subject { described_class.default_generate_indexing }
|
90
90
|
|
91
91
|
context 'when not explicitly set' do
|
92
|
-
it {
|
92
|
+
it { is_expected.to eq(true) }
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'when explicitly set' do
|
96
96
|
before { described_class.default_generate_indexing = false }
|
97
97
|
after { described_class.default_generate_indexing = true }
|
98
|
-
it {
|
98
|
+
it { is_expected.to eq(false) }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#max_index_and_constraint_name_length' do
|
103
|
+
subject { described_class.max_index_and_constraint_name_length }
|
104
|
+
|
105
|
+
context 'when not explicitly set' do
|
106
|
+
it { is_expected.to eq(64) }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when explicitly set' do
|
110
|
+
around do |spec|
|
111
|
+
orig_value = described_class.max_index_and_constraint_name_length
|
112
|
+
described_class.max_index_and_constraint_name_length = max_index_and_constraint_name_length
|
113
|
+
spec.run
|
114
|
+
rescue
|
115
|
+
described_class.max_index_and_constraint_name_length = orig_value
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when set to an Integer' do
|
119
|
+
let(:max_index_and_constraint_name_length) { 255 }
|
120
|
+
|
121
|
+
it { is_expected.to eq(255)}
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when set to nil' do
|
125
|
+
let(:max_index_and_constraint_name_length) { nil }
|
126
|
+
|
127
|
+
it { is_expected.to eq(nil)}
|
128
|
+
end
|
99
129
|
end
|
100
130
|
end
|
101
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: declare_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -47,10 +47,9 @@ files:
|
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
49
|
- bin/declare_schema
|
50
|
+
- config/brakeman.ignore
|
50
51
|
- declare_schema.gemspec
|
51
52
|
- gemfiles/.bundle/config
|
52
|
-
- gemfiles/rails_5_mysql.gemfile
|
53
|
-
- gemfiles/rails_5_sqlite.gemfile
|
54
53
|
- gemfiles/rails_6_mysql.gemfile
|
55
54
|
- gemfiles/rails_6_sqlite.gemfile
|
56
55
|
- lib/declare_schema.rb
|
@@ -142,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
141
|
- !ruby/object:Gem::Version
|
143
142
|
version: 1.3.6
|
144
143
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.4.6
|
146
145
|
signing_key:
|
147
146
|
specification_version: 4
|
148
147
|
summary: Database schema declaration and migration generator for Rails
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "climate_control", "~> 0.2"
|
7
|
-
gem "pry"
|
8
|
-
gem "pry-byebug"
|
9
|
-
gem "rails", "~> 5.2"
|
10
|
-
gem "responders"
|
11
|
-
gem "rspec"
|
12
|
-
gem "rubocop"
|
13
|
-
gem "yard"
|
14
|
-
gem "mysql2"
|
15
|
-
|
16
|
-
group :testapp do
|
17
|
-
gem "bootsnap", ">= 1.1.0", require: false
|
18
|
-
gem "listen"
|
19
|
-
end
|
20
|
-
|
21
|
-
gemspec path: "../"
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "climate_control", "~> 0.2"
|
7
|
-
gem "pry"
|
8
|
-
gem "pry-byebug"
|
9
|
-
gem "rails", "~> 5.2"
|
10
|
-
gem "responders"
|
11
|
-
gem "rspec"
|
12
|
-
gem "rubocop"
|
13
|
-
gem "yard"
|
14
|
-
gem "sqlite3"
|
15
|
-
|
16
|
-
group :testapp do
|
17
|
-
gem "bootsnap", ">= 1.1.0", require: false
|
18
|
-
gem "listen"
|
19
|
-
end
|
20
|
-
|
21
|
-
gemspec path: "../"
|