declare_schema 1.3.0.colin.1 → 1.3.1.colin.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1ca385b5ea18e46f1d2c9faa5f21f05dd1d76783806fcd10041c5102464115b
4
- data.tar.gz: f96cbe0cf82a99087f4dbfbc4c35199236d75ec64c79d9f290df2b7f6266920d
3
+ metadata.gz: a0f533d7dc8d88f7a84002c3f683cc4afa1a50af764fb6f478fb6d21f06d3d00
4
+ data.tar.gz: a033eb5411618bf7d0e1beb51176aa682a7362820df942df52f9d87818875237
5
5
  SHA512:
6
- metadata.gz: a203a826b62f2d37ac5f5cef73f660b5ebb14ec0009ba50d196612090a1445fe9c20e6ce90be9371b005248cf1391fb5565246bf87cb50f261f4f228b63848c2
7
- data.tar.gz: 66cda6583ab4b15c0592220369f75a23b9c5cf2467338dca4082ac4e497d787cf40ad3a48b01b1e4b306715a026e1f79f0718b0271a32bbb8a5c4cc8f200c884
6
+ metadata.gz: eb1c42caab31adbd01450a2c94c7a15d4c535bc1e8b89a50370f95796adad9bc21d297969c463febc77f7ba3f64ccd4a79cb68480bf02baff2f864302f435cd1
7
+ data.tar.gz: f2882b79e6eadd987d064e9adb742e5d2adea31c1de9a716fdd5a05a1c6a9e54491b8d5825ef9f310038e430ca2c54af08dad0c389202ff101a659065dc6b942
@@ -10,21 +10,10 @@ jobs:
10
10
  strategy:
11
11
  fail-fast: false
12
12
  matrix:
13
- ruby: [2.6, 2.7, '3.0', 3.1]
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.7.5
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,7 +4,12 @@ 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] - Unreleased
7
+ ## [1.3.1] - Unreleased
8
+ ### Fixed
9
+ - Fix bug in default index anme when table name + __ + column suffix exceeds `DeclareSchema.max_index_and_constraint_name_length`.
10
+ In this case we truncate the table name and append part of its hash.
11
+
12
+ ## [1.3.0] - 2023-07-10
8
13
  ### Added
9
14
  - Added `DeclareSchema.max_index_and_constraint_name_length` with default of 64.
10
15
 
data/Gemfile.lock CHANGED
@@ -1,66 +1,66 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (1.3.0.colin.1)
4
+ declare_schema (1.3.1.colin.1)
5
5
  rails (>= 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.1.5)
11
- actionpack (= 6.1.5)
12
- activesupport (= 6.1.5)
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.5)
16
- actionpack (= 6.1.5)
17
- activejob (= 6.1.5)
18
- activerecord (= 6.1.5)
19
- activestorage (= 6.1.5)
20
- activesupport (= 6.1.5)
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.5)
23
- actionpack (= 6.1.5)
24
- actionview (= 6.1.5)
25
- activejob (= 6.1.5)
26
- activesupport (= 6.1.5)
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.5)
30
- actionview (= 6.1.5)
31
- activesupport (= 6.1.5)
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.5)
37
- actionpack (= 6.1.5)
38
- activerecord (= 6.1.5)
39
- activestorage (= 6.1.5)
40
- activesupport (= 6.1.5)
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.5)
43
- activesupport (= 6.1.5)
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.5)
49
- activesupport (= 6.1.5)
48
+ activejob (6.1.7.4)
49
+ activesupport (= 6.1.7.4)
50
50
  globalid (>= 0.3.6)
51
- activemodel (6.1.5)
52
- activesupport (= 6.1.5)
53
- activerecord (6.1.5)
54
- activemodel (= 6.1.5)
55
- activesupport (= 6.1.5)
56
- activestorage (6.1.5)
57
- actionpack (= 6.1.5)
58
- activejob (= 6.1.5)
59
- activerecord (= 6.1.5)
60
- activesupport (= 6.1.5)
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.5)
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.1)
74
- bootsnap (1.7.2)
75
- msgpack (~> 1.0)
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.1.10)
80
+ concurrent-ruby (1.2.2)
81
81
  crass (1.0.6)
82
- diff-lcs (1.4.4)
83
- digest (3.1.0)
84
- erubi (1.10.0)
85
- ffi (1.15.1)
86
- globalid (1.0.0)
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.10.0)
88
+ i18n (1.14.1)
89
89
  concurrent-ruby (~> 1.0)
90
- io-wait (0.2.1)
91
- listen (3.5.1)
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.15.0)
95
+ loofah (2.21.3)
95
96
  crass (~> 1.0.2)
96
- nokogiri (>= 1.5.9)
97
- mail (2.7.1)
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.0)
103
- minitest (5.15.0)
104
- msgpack (1.4.2)
105
- net-protocol (0.1.2)
106
- io-wait
107
- timeout
108
- net-smtp (0.3.1)
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
- nio4r (2.5.8)
113
- nokogiri (1.13.3)
114
- mini_portile2 (~> 2.8.0)
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.19.2)
117
- parser (2.7.1.4)
122
+ parallel (1.23.0)
123
+ parser (3.2.2.3)
118
124
  ast (~> 2.4.1)
119
- pry (0.13.1)
125
+ racc
126
+ pry (0.14.2)
120
127
  coderay (~> 1.1)
121
128
  method_source (~> 1.0)
122
- pry-byebug (3.9.0)
129
+ pry-byebug (3.10.1)
123
130
  byebug (~> 11.0)
124
- pry (~> 0.13.0)
125
- racc (1.6.0)
126
- rack (2.2.3)
127
- rack-test (1.1.0)
128
- rack (>= 1.0, < 3)
129
- rails (6.1.5)
130
- actioncable (= 6.1.5)
131
- actionmailbox (= 6.1.5)
132
- actionmailer (= 6.1.5)
133
- actionpack (= 6.1.5)
134
- actiontext (= 6.1.5)
135
- actionview (= 6.1.5)
136
- activejob (= 6.1.5)
137
- activemodel (= 6.1.5)
138
- activerecord (= 6.1.5)
139
- activestorage (= 6.1.5)
140
- activesupport (= 6.1.5)
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.5)
149
+ railties (= 6.1.7.4)
143
150
  sprockets-rails (>= 2.0.0)
144
- rails-dom-testing (2.0.3)
145
- activesupport (>= 4.2.0)
151
+ rails-dom-testing (2.1.1)
152
+ activesupport (>= 5.0.0)
153
+ minitest
146
154
  nokogiri (>= 1.6)
147
- rails-html-sanitizer (1.4.2)
148
- loofah (~> 2.3)
149
- railties (6.1.5)
150
- actionpack (= 6.1.5)
151
- activesupport (= 6.1.5)
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.0.0)
164
+ rainbow (3.1.1)
156
165
  rake (13.0.6)
157
- rb-fsevent (0.11.0)
166
+ rb-fsevent (0.11.2)
158
167
  rb-inotify (0.10.1)
159
168
  ffi (~> 1.0)
160
- regexp_parser (1.8.0)
161
- responders (3.0.1)
162
- actionpack (>= 5.0)
163
- railties (>= 5.0)
164
- rexml (3.2.4)
165
- rspec (3.10.0)
166
- rspec-core (~> 3.10.0)
167
- rspec-expectations (~> 3.10.0)
168
- rspec-mocks (~> 3.10.0)
169
- rspec-core (3.10.0)
170
- rspec-support (~> 3.10.0)
171
- rspec-expectations (3.10.0)
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.10.0)
174
- rspec-mocks (3.10.0)
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.10.0)
177
- rspec-support (3.10.0)
178
- rubocop (0.91.0)
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.7.1.1)
191
+ parser (>= 3.2.2.3)
181
192
  rainbow (>= 2.2.2, < 4.0)
182
- regexp_parser (>= 1.7)
183
- rexml
184
- rubocop-ast (>= 0.4.0, < 1.0)
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 (>= 1.4.0, < 2.0)
187
- rubocop-ast (0.4.2)
188
- parser (>= 2.7.1.4)
189
- ruby-progressbar (1.10.1)
190
- sprockets (4.0.3)
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 (> 1, < 3)
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.4.2)
198
- thor (1.2.1)
199
- timeout (0.2.0)
200
- tzinfo (2.0.4)
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 (1.7.0)
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.26)
207
- zeitwerk (2.5.4)
218
+ yard (0.9.34)
219
+ zeitwerk (2.6.8)
208
220
 
209
221
  PLATFORMS
210
222
  ruby
@@ -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
+ }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'digest/sha2'
4
+
3
5
  module DeclareSchema
4
6
  module Model
5
7
  class IndexDefinition
@@ -69,12 +71,30 @@ module DeclareSchema
69
71
 
70
72
  private
71
73
 
74
+ SHA_SUFFIX_LENGTH = 4
75
+
76
+ def shorten_name(name, max_len)
77
+ if name.size <= max_len
78
+ name
79
+ else
80
+ name_prefix = name.first(max_len >= SHA_SUFFIX_LENGTH*2 ? (max_len - SHA_SUFFIX_LENGTH) : ((max_len + 1)/2))
81
+ sha = Digest::SHA256.hexdigest(name)
82
+ (name_prefix + sha).first(max_len)
83
+ end
84
+ end
85
+
72
86
  def long_index_name(table_name, columns)
73
87
  "index_#{table_name}_on_#{Array(columns).join("_and_")}"
74
88
  end
75
89
 
76
90
  def short_index_name(table_name, columns)
77
- "#{table_name}__#{Array(columns).join("_")}"
91
+ columns_suffix = "__" + Array(columns).join('_')
92
+ if DeclareSchema.max_index_and_constraint_name_length.nil?
93
+ table_name + columns_suffix
94
+ else
95
+ max_name_len = [DeclareSchema.max_index_and_constraint_name_length - columns_suffix.length, 0].max
96
+ shorten_name(table_name, max_name_len) + columns_suffix
97
+ end
78
98
  end
79
99
  end
80
100
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeclareSchema
4
- VERSION = "1.3.0.colin.1"
4
+ VERSION = "1.3.1.colin.1"
5
5
  end
@@ -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: :index_adverts_on_category_id
870
- add_index :affiliates, [:category_id], name: :index_adverts_on_category_id
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
@@ -133,6 +133,46 @@ RSpec.describe DeclareSchema::Model::IndexDefinition do
133
133
 
134
134
  it { is_expected.to eq("users__last_name_first_name_middle_name") }
135
135
  end
136
+
137
+ context 'with long table name' do
138
+ let(:table_name2) { 'user_domains_extra' }
139
+ {
140
+ 34 => '__last_name_first_name_middle_name',
141
+ 35 => 'u__last_name_first_name_middle_name',
142
+ 36 => 'u4__last_name_first_name_middle_name',
143
+ 37 => 'us4__last_name_first_name_middle_name',
144
+ 38 => 'us48__last_name_first_name_middle_name',
145
+ 39 => 'use48__last_name_first_name_middle_name',
146
+ 40 => 'use481__last_name_first_name_middle_name',
147
+ 41 => 'user481__last_name_first_name_middle_name',
148
+ 42 => 'user4814__last_name_first_name_middle_name',
149
+ 43 => 'user_4814__last_name_first_name_middle_name',
150
+ 44 => 'user_d4814__last_name_first_name_middle_name',
151
+ 45 => 'user_do4814__last_name_first_name_middle_name',
152
+ 46 => 'user_dom4814__last_name_first_name_middle_name',
153
+ 47 => 'user_doma4814__last_name_first_name_middle_name',
154
+ 48 => 'user_domai4814__last_name_first_name_middle_name',
155
+ 49 => 'user_domain4814__last_name_first_name_middle_name',
156
+ 50 => 'user_domains4814__last_name_first_name_middle_name',
157
+ 51 => 'user_domains_4814__last_name_first_name_middle_name',
158
+ 52 => 'user_domains_extra__last_name_first_name_middle_name',
159
+ }.each do |len, index_name|
160
+ context "with max_index_and_constraint_name_length of #{len}" do
161
+ let(:max_index_and_constraint_name_length) { len }
162
+
163
+ it { is_expected.to eq(index_name) }
164
+ end
165
+ end
166
+
167
+ context "with max_index_and_constraint_name_length shorter than columns suffix" do
168
+ let(:max_index_and_constraint_name_length) { 33 }
169
+
170
+ it 'raises' do
171
+ expect { subject }.to raise_exception(DeclareSchema::Model::IndexDefinition::IndexNameTooLongError,
172
+ /Index '__last_name_first_name_middle_name' exceeds configured limit of 33 characters/)
173
+ end
174
+ end
175
+ end
136
176
  end
137
177
  end
138
178
  # TODO: fill out remaining tests
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.3.0.colin.1
4
+ version: 1.3.1.colin.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development adapted from hobo_fields by Tom Locke
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-03 00:00:00.000000000 Z
11
+ date: 2023-10-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
@@ -127,7 +126,7 @@ homepage: https://github.com/Invoca/declare_schema
127
126
  licenses: []
128
127
  metadata:
129
128
  allowed_push_host: https://rubygems.org
130
- post_install_message:
129
+ post_install_message:
131
130
  rdoc_options: []
132
131
  require_paths:
133
132
  - lib
@@ -142,8 +141,8 @@ 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.1.6
146
- signing_key:
144
+ rubygems_version: 3.4.6
145
+ signing_key:
147
146
  specification_version: 4
148
147
  summary: Database schema declaration and migration generator for Rails
149
148
  test_files: []
@@ -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: "../"