declare_schema 0.14.2 → 1.0.1

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/workflows/declare_schema_build.yml +22 -23
  4. data/.ruby-version +1 -1
  5. data/Appraisals +8 -0
  6. data/CHANGELOG.md +22 -4
  7. data/Gemfile +3 -2
  8. data/Gemfile.lock +107 -77
  9. data/README.md +18 -8
  10. data/Rakefile +1 -1
  11. data/gemfiles/rails_5_mysql.gemfile +0 -1
  12. data/gemfiles/rails_5_sqlite.gemfile +0 -1
  13. data/gemfiles/rails_6_mysql.gemfile +2 -1
  14. data/gemfiles/rails_6_sqlite.gemfile +2 -1
  15. data/lib/declare_schema/command.rb +1 -1
  16. data/lib/declare_schema/dsl.rb +2 -2
  17. data/lib/declare_schema/extensions/active_record/fields_declaration.rb +0 -18
  18. data/lib/declare_schema/field_declaration_dsl.rb +4 -4
  19. data/lib/declare_schema/model/foreign_key_definition.rb +2 -2
  20. data/lib/declare_schema/model/index_definition.rb +2 -2
  21. data/lib/declare_schema/model/table_options_definition.rb +2 -2
  22. data/lib/declare_schema/model.rb +9 -9
  23. data/lib/declare_schema/version.rb +1 -1
  24. data/lib/generators/declare_schema/migration/migrator.rb +6 -6
  25. data/spec/lib/declare_schema/field_declaration_dsl_spec.rb +0 -24
  26. data/spec/lib/declare_schema/field_spec_spec.rb +2 -2
  27. data/spec/lib/declare_schema/interactive_primary_key_spec.rb +0 -67
  28. data/spec/lib/declare_schema/migration_generator_spec.rb +11 -1176
  29. data/spec/lib/declare_schema/model/column_spec.rb +1 -28
  30. data/spec/lib/declare_schema/model/foreign_key_definition_spec.rb +1 -94
  31. data/spec/lib/declare_schema/model/index_definition_spec.rb +0 -109
  32. data/spec/lib/declare_schema/model/table_options_definition_spec.rb +2 -65
  33. data/spec/lib/declare_schema/schema_change/column_add_spec.rb +1 -1
  34. data/spec/lib/declare_schema/schema_change/column_remove_spec.rb +1 -1
  35. data/spec/spec_helper.rb +1 -1
  36. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2804b7a11446f5570e967f4ea65be3ee2da5af62a54c3a345acfd2d9b9f58d7b
4
- data.tar.gz: 1c1787e5388145ec1a8ae81276fda0488be7fc2d7e192355aaf8d76ef0c00005
3
+ metadata.gz: 165053edc0bb071619bb898609cd3e8d489589509de8a386e3cfe97c63efd372
4
+ data.tar.gz: '05338b95ee665d86973b61aa36c35189f531660f325c3849890ae38cc356c5b8'
5
5
  SHA512:
6
- metadata.gz: 2eaff1f5f1e0e0ded155db135646df64a9e38a04c64511550e98ed7857e182b63f45558b309dcbaf93d3a22bff6781b95b94418aa90604fbdafda076384bbde5
7
- data.tar.gz: a8e380d8e2b1fadf9aeceeea58d3a2a1503330191dcb8f4f4fc507f7b6d191b4dec2f191e94820d7fb21efacfc95c571e5589612517904c48d91dde2d2866973
6
+ metadata.gz: f84b58499f9d1e5b4e5d5c74af3c4e3cedbbc839076f09d128be9f92df7f7a61354d5de0531804ce3d2a3b6ec8c437a35c5d777cb44b5c1c2eb7d8a28f310095
7
+ data.tar.gz: 0b2403c1d17d52cecc73ab7be84729cba4979c34c9e48d1099f0ffaf4c97721f698dbced48e7f70571c476e3139829183fcac6b2957a5cea103b9cd8f49ba845
@@ -0,0 +1 @@
1
+ * @Invoca/octothorpe
@@ -8,18 +8,29 @@ jobs:
8
8
  name: DeclareSchema Build
9
9
  runs-on: ubuntu-latest
10
10
  strategy:
11
+ fail-fast: false
11
12
  matrix:
12
- ruby: [ 2.4.5, 2.5.8, 2.6.5, 2.7.1 ]
13
+ ruby: [2.6, 2.7, '3.0', 3.1]
13
14
  gemfile:
14
15
  - gemfiles/rails_5_mysql.gemfile
15
16
  - gemfiles/rails_5_sqlite.gemfile
16
17
  - gemfiles/rails_6_mysql.gemfile
17
18
  - gemfiles/rails_6_sqlite.gemfile
19
+ include:
20
+ - gemfile: gemfiles/rails_5_mysql.gemfile
21
+ ruby: 2.5
22
+ - gemfile: gemfiles/rails_5_sqlite.gemfile
23
+ ruby: 2.5
18
24
  exclude:
19
- - { gemfile: gemfiles/rails_5_mysql.gemfile, ruby: 2.4.5 }
20
- - { gemfile: gemfiles/rails_5_sqlite.gemfile, ruby: 2.4.5 }
21
- - { gemfile: gemfiles/rails_6_mysql.gemfile, ruby: 2.4.5 }
22
- - { gemfile: gemfiles/rails_6_sqlite.gemfile, ruby: 2.4.5 }
25
+ - ruby: '3.0'
26
+ gemfile: gemfiles/rails_5_mysql.gemfile
27
+ - ruby: 3.1
28
+ gemfile: gemfiles/rails_5_mysql.gemfile
29
+ - ruby: '3.0'
30
+ gemfile: gemfiles/rails_5_sqlite.gemfile
31
+ - ruby: 3.1
32
+ gemfile: gemfiles/rails_5_sqlite.gemfile
33
+
23
34
  env:
24
35
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
25
36
  services:
@@ -30,27 +41,15 @@ jobs:
30
41
  ports:
31
42
  - 3306:3306
32
43
  steps:
33
- - name: Checkout Branch
34
- id: checkout_branch
35
- uses: actions/checkout@v2
36
- - name: Setup Ruby
37
- id: setup_ruby
38
- uses: ruby/setup-ruby@v1
44
+ - uses: actions/checkout@v2
45
+ - uses: ruby/setup-ruby@v1
39
46
  with:
40
- bundler: 1.17.3
41
47
  ruby-version: ${{matrix.ruby}}
42
- - name: Remove Bundler 2
43
- id: remove_bundler_2
44
- if: ${{ matrix.ruby >= '2.6.5' }}
45
- run: |
46
- rm -f /opt/hostedtoolcache/Ruby/2.*/x64/lib/ruby/gems/2.*/specifications/default/bundler-2.*.gemspec
47
- gem install bundler:1.17.3 --force --default
48
- gem install bundler -v 1.17.3
49
- - name: Appraisals
50
- id: appraisals
48
+ bundler: 2.2.29
49
+ bundler-cache: true
50
+ - name: Setup
51
51
  run: |
52
- bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle} --gemfile=${{ matrix.gemfile }}
53
52
  git config --global user.email "dummy@example.com"
54
53
  git config --global user.name "dummy"
55
54
  MYSQL_PORT=3306 bundle exec rake test:prepare_testapp[force]
56
- bundle exec rake test:all
55
+ - run: bundle exec rake test:all
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.0
1
+ 2.7.5
data/Appraisals CHANGED
@@ -3,11 +3,18 @@
3
3
  appraise 'rails-5-sqlite' do
4
4
  gem 'rails', '~> 5.2'
5
5
  gem 'sqlite3'
6
+
7
+ remove_gem 'mail'
8
+ remove_gem 'net-smtp'
6
9
  end
7
10
 
8
11
  appraise 'rails-5-mysql' do
9
12
  gem 'rails', '~> 5.2'
10
13
  gem 'mysql2'
14
+
15
+ remove_gem 'mail'
16
+ remove_gem 'net-smtp'
17
+ remove_gem 'sqlite3'
11
18
  end
12
19
 
13
20
  appraise 'rails-6-sqlite' do
@@ -18,4 +25,5 @@ end
18
25
  appraise 'rails-6-mysql' do
19
26
  gem 'rails', '~> 6.1'
20
27
  gem 'mysql2'
28
+ remove_gem 'sqlite3'
21
29
  end
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ 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.0.1] - 2022-07-12
8
+ ### Fixed
9
+ - Remove lingering usage of `fallback_find_primary_key` method that was removed in `0.14.0`
10
+
11
+ ## [1.0.0] - 2022-03-28
12
+ ### Added
13
+ - Added support for Ruby 3+
14
+
15
+ ### Removed
16
+ - Removed deprecated `fields` block declaration
17
+
18
+ ## [0.14.3] - 2021-09-01
19
+ ### Fixed
20
+ - Fixed more Ruby 2.7 warnings about needing `**options` when calling a method that has `**options` in its signature.
21
+
7
22
  ## [0.14.2] - 2021-09-01
8
23
  ### Fixed
9
24
  - Fixed another Ruby 2.7 warning about needing `**options` when calling a method that has `**options` in its signature.
@@ -14,7 +29,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
14
29
 
15
30
  ## [0.14.0] - 2021-08-10
16
31
  ### Removed
17
- - Dropped support for Rails versions less than 5.
32
+ - Dropped support for Rails versions less than 5.
18
33
 
19
34
  ## [0.13.2] - 2021-08-04
20
35
  ### Fixed
@@ -51,7 +66,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
51
66
  The migration will be run if `--migrate` is passed; otherwise, the migrate command will be displayed to be run later.
52
67
  ### Added
53
68
  - Added the new configuration option `DeclareSchema.@db_migrate_command =`.
54
- ### Fixed
69
+ ### Fixed
55
70
  - Fixed bug where foreign key constraint names are not globally unique
56
71
 
57
72
  ## [0.10.1] - 2021-03-18
@@ -105,7 +120,7 @@ i.e. `declare schema { string :title }`. Otherwise, there is no difference betwe
105
120
  ### Fixed
106
121
  - Fixed a bug in migration generation caused by `DeclareSchema::Migration#create_constraints`
107
122
  calling `DeclareSchema::Model::ForeignKeyDefinition#to_add_statement` with unused parameters.
108
-
123
+
109
124
  - Fixed a bug in `DeclareSchema::Migration#remove_foreign_key` where special characters would not be quoted properly.
110
125
 
111
126
  ## [0.6.2] - 2021-01-06
@@ -130,7 +145,7 @@ because all of the existing primary key columns are being removed.
130
145
  - FieldSpec#initialize interface now includes `position` keyword argument and `**options` hash.
131
146
 
132
147
  ### Fixed
133
- - Fixed cycle in which FieldSpec#initialize was calling `model.field_specs`
148
+ - Fixed cycle in which FieldSpec#initialize was calling `model.field_specs`
134
149
 
135
150
  ### Changed
136
151
  - Changed ci support from Travis to Github Workflow
@@ -204,6 +219,9 @@ using the appropriate Rails configuration attributes.
204
219
  ### Added
205
220
  - Initial version from https://github.com/Invoca/hobo_fields v4.1.0.
206
221
 
222
+ [1.0.1]: https://github.com/Invoca/declare_schema/compare/v1.0.0...v1.0.1
223
+ [1.0.0]: https://github.com/Invoca/declare_schema/compare/v0.14.3...v1.0.0
224
+ [0.14.3]: https://github.com/Invoca/declare_schema/compare/v0.14.2...v0.14.3
207
225
  [0.14.2]: https://github.com/Invoca/declare_schema/compare/v0.14.1...v0.14.2
208
226
  [0.14.1]: https://github.com/Invoca/declare_schema/compare/v0.14.0...v0.14.1
209
227
  [0.14.0]: https://github.com/Invoca/declare_schema/compare/v0.13.1...v0.14.0
data/Gemfile CHANGED
@@ -10,11 +10,12 @@ group :testapp do
10
10
  end
11
11
 
12
12
  gem 'appraisal'
13
- gem 'bundler', '< 2'
14
13
  gem "climate_control", '~> 0.2'
14
+ gem 'mail'
15
+ gem 'net-smtp'
15
16
  gem 'pry'
16
17
  gem 'pry-byebug'
17
- gem 'rails', '~> 5.2', '>= 5.2.4.3'
18
+ gem 'rails', '~> 6.0'
18
19
  gem 'responders'
19
20
  gem 'rspec'
20
21
  gem 'rubocop'
data/Gemfile.lock CHANGED
@@ -1,58 +1,75 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (0.14.2)
4
+ declare_schema (1.0.1)
5
5
  rails (>= 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.6)
11
- actionpack (= 5.2.6)
10
+ actioncable (6.1.5)
11
+ actionpack (= 6.1.5)
12
+ activesupport (= 6.1.5)
12
13
  nio4r (~> 2.0)
13
14
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.6)
15
- actionpack (= 5.2.6)
16
- actionview (= 5.2.6)
17
- activejob (= 5.2.6)
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)
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)
18
27
  mail (~> 2.5, >= 2.5.4)
19
28
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.6)
21
- actionview (= 5.2.6)
22
- activesupport (= 5.2.6)
23
- rack (~> 2.0, >= 2.0.8)
29
+ actionpack (6.1.5)
30
+ actionview (= 6.1.5)
31
+ activesupport (= 6.1.5)
32
+ rack (~> 2.0, >= 2.0.9)
24
33
  rack-test (>= 0.6.3)
25
34
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.6)
28
- activesupport (= 5.2.6)
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)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.5)
43
+ activesupport (= 6.1.5)
29
44
  builder (~> 3.1)
30
45
  erubi (~> 1.4)
31
46
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.6)
34
- activesupport (= 5.2.6)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.5)
49
+ activesupport (= 6.1.5)
35
50
  globalid (>= 0.3.6)
36
- activemodel (5.2.6)
37
- activesupport (= 5.2.6)
38
- activerecord (5.2.6)
39
- activemodel (= 5.2.6)
40
- activesupport (= 5.2.6)
41
- arel (>= 9.0)
42
- activestorage (5.2.6)
43
- actionpack (= 5.2.6)
44
- activerecord (= 5.2.6)
45
- marcel (~> 1.0.0)
46
- activesupport (5.2.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)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.5)
47
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
- i18n (>= 0.7, < 2)
49
- minitest (~> 5.1)
50
- tzinfo (~> 1.1)
51
- appraisal (2.3.0)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ appraisal (2.4.1)
52
70
  bundler
53
71
  rake
54
72
  thor (>= 0.14.0)
55
- arel (9.0.0)
56
73
  ast (2.4.1)
57
74
  bootsnap (1.7.2)
58
75
  msgpack (~> 1.0)
@@ -60,32 +77,41 @@ GEM
60
77
  byebug (11.1.3)
61
78
  climate_control (0.2.0)
62
79
  coderay (1.1.3)
63
- concurrent-ruby (1.1.9)
80
+ concurrent-ruby (1.1.10)
64
81
  crass (1.0.6)
65
82
  diff-lcs (1.4.4)
83
+ digest (3.1.0)
66
84
  erubi (1.10.0)
67
85
  ffi (1.15.1)
68
- globalid (0.4.2)
69
- activesupport (>= 4.2.0)
70
- i18n (1.8.10)
86
+ globalid (1.0.0)
87
+ activesupport (>= 5.0)
88
+ i18n (1.10.0)
71
89
  concurrent-ruby (~> 1.0)
90
+ io-wait (0.2.1)
72
91
  listen (3.5.1)
73
92
  rb-fsevent (~> 0.10, >= 0.10.3)
74
93
  rb-inotify (~> 0.9, >= 0.9.10)
75
- loofah (2.10.0)
94
+ loofah (2.15.0)
76
95
  crass (~> 1.0.2)
77
96
  nokogiri (>= 1.5.9)
78
97
  mail (2.7.1)
79
98
  mini_mime (>= 0.1.1)
80
- marcel (1.0.1)
99
+ marcel (1.0.2)
81
100
  method_source (1.0.0)
82
- mini_mime (1.1.0)
83
- mini_portile2 (2.5.3)
84
- minitest (5.14.4)
101
+ mini_mime (1.1.2)
102
+ mini_portile2 (2.8.0)
103
+ minitest (5.15.0)
85
104
  msgpack (1.4.2)
86
- nio4r (2.5.7)
87
- nokogiri (1.11.7)
88
- mini_portile2 (~> 2.5.0)
105
+ net-protocol (0.1.2)
106
+ io-wait
107
+ timeout
108
+ net-smtp (0.3.1)
109
+ digest
110
+ net-protocol
111
+ timeout
112
+ nio4r (2.5.8)
113
+ nokogiri (1.13.3)
114
+ mini_portile2 (~> 2.8.0)
89
115
  racc (~> 1.4)
90
116
  parallel (1.19.2)
91
117
  parser (2.7.1.4)
@@ -96,36 +122,38 @@ GEM
96
122
  pry-byebug (3.9.0)
97
123
  byebug (~> 11.0)
98
124
  pry (~> 0.13.0)
99
- racc (1.5.2)
125
+ racc (1.6.0)
100
126
  rack (2.2.3)
101
127
  rack-test (1.1.0)
102
128
  rack (>= 1.0, < 3)
103
- rails (5.2.6)
104
- actioncable (= 5.2.6)
105
- actionmailer (= 5.2.6)
106
- actionpack (= 5.2.6)
107
- actionview (= 5.2.6)
108
- activejob (= 5.2.6)
109
- activemodel (= 5.2.6)
110
- activerecord (= 5.2.6)
111
- activestorage (= 5.2.6)
112
- activesupport (= 5.2.6)
113
- bundler (>= 1.3.0)
114
- railties (= 5.2.6)
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)
141
+ bundler (>= 1.15.0)
142
+ railties (= 6.1.5)
115
143
  sprockets-rails (>= 2.0.0)
116
144
  rails-dom-testing (2.0.3)
117
145
  activesupport (>= 4.2.0)
118
146
  nokogiri (>= 1.6)
119
- rails-html-sanitizer (1.3.0)
147
+ rails-html-sanitizer (1.4.2)
120
148
  loofah (~> 2.3)
121
- railties (5.2.6)
122
- actionpack (= 5.2.6)
123
- activesupport (= 5.2.6)
149
+ railties (6.1.5)
150
+ actionpack (= 6.1.5)
151
+ activesupport (= 6.1.5)
124
152
  method_source
125
- rake (>= 0.8.7)
126
- thor (>= 0.19.0, < 2.0)
153
+ rake (>= 12.2)
154
+ thor (~> 1.0)
127
155
  rainbow (3.0.0)
128
- rake (13.0.3)
156
+ rake (13.0.6)
129
157
  rb-fsevent (0.11.0)
130
158
  rb-inotify (0.10.1)
131
159
  ffi (~> 1.0)
@@ -159,23 +187,24 @@ GEM
159
187
  rubocop-ast (0.4.2)
160
188
  parser (>= 2.7.1.4)
161
189
  ruby-progressbar (1.10.1)
162
- sprockets (4.0.2)
190
+ sprockets (4.0.3)
163
191
  concurrent-ruby (~> 1.0)
164
192
  rack (> 1, < 3)
165
- sprockets-rails (3.2.2)
166
- actionpack (>= 4.0)
167
- activesupport (>= 4.0)
193
+ sprockets-rails (3.4.2)
194
+ actionpack (>= 5.2)
195
+ activesupport (>= 5.2)
168
196
  sprockets (>= 3.0.0)
169
197
  sqlite3 (1.4.2)
170
- thor (1.1.0)
171
- thread_safe (0.3.6)
172
- tzinfo (1.2.9)
173
- thread_safe (~> 0.1)
198
+ thor (1.2.1)
199
+ timeout (0.2.0)
200
+ tzinfo (2.0.4)
201
+ concurrent-ruby (~> 1.0)
174
202
  unicode-display_width (1.7.0)
175
- websocket-driver (0.7.4)
203
+ websocket-driver (0.7.5)
176
204
  websocket-extensions (>= 0.1.0)
177
205
  websocket-extensions (0.1.5)
178
206
  yard (0.9.26)
207
+ zeitwerk (2.5.4)
179
208
 
180
209
  PLATFORMS
181
210
  ruby
@@ -183,13 +212,14 @@ PLATFORMS
183
212
  DEPENDENCIES
184
213
  appraisal
185
214
  bootsnap (>= 1.1.0)
186
- bundler (< 2)
187
215
  climate_control (~> 0.2)
188
216
  declare_schema!
189
217
  listen
218
+ mail
219
+ net-smtp
190
220
  pry
191
221
  pry-byebug
192
- rails (~> 5.2, >= 5.2.4.3)
222
+ rails (~> 6.0)
193
223
  responders
194
224
  rspec
195
225
  rubocop
@@ -197,4 +227,4 @@ DEPENDENCIES
197
227
  yard
198
228
 
199
229
  BUNDLED WITH
200
- 1.17.3
230
+ 2.2.29
data/README.md CHANGED
@@ -8,10 +8,10 @@ Make a model and declare your schema within a `declare_schema do ... end` block:
8
8
  ```ruby
9
9
  class Company < ActiveRecord::Base
10
10
  declare_schema do
11
- company_name :string, limit: 100
12
- ticker_symbol :string, limit: 4, null: true, index: true, unique: true
13
- employee_count :integer
14
- comments :text
11
+ string :company_name, limit: 100
12
+ string :ticker_symbol, limit: 4, null: true, index: true, unique: true
13
+ integer :employee_count
14
+ text :comments
15
15
 
16
16
  timestamps
17
17
  end
@@ -50,6 +50,16 @@ Migration filename: [<enter>=declare_schema_migration_1|<custom_name>]: add_comp
50
50
  ```
51
51
  Note that the migration generator is interactive -- it can't tell the difference between renaming something vs. adding one thing and removing another, so sometimes it will ask you to clarify.
52
52
 
53
+ ## declare_schema macro options
54
+
55
+ Any options provided to the `declare_schema` macro will be passed on to `create_table`. For example, to set the `id` column of the table explicitly to `:bigint`:
56
+ ```
57
+ declare_schema id: :bigint do
58
+ string :company_name, limit: 100
59
+ ...
60
+ end
61
+ ```
62
+
53
63
  ## Migrator Configuration
54
64
 
55
65
  The following configuration options are available for the gem and can be used
@@ -224,8 +234,8 @@ like the following:
224
234
 
225
235
  class Comment < ActiveRecord::Base
226
236
  declare_schema charset: "utf8mb4", collation: "utf8mb4_bin" do
227
- subject :string, limit: 255
228
- content :text, limit: 0xffff_ffff
237
+ string :subject, limit: 255
238
+ text :content, limit: 0xffff_ffff
229
239
  end
230
240
  end
231
241
  ```
@@ -244,8 +254,8 @@ look like the following:
244
254
 
245
255
  class Comment < ActiveRecord::Base
246
256
  declare_schema do
247
- subject :string, limit: 255
248
- context :text, limit: 0xffff_ffff, charset: "utf8mb4", collation: "utf8mb4_bin"
257
+ string :subject, limit: 255
258
+ text :context, limit: 0xffff_ffff, charset: "utf8mb4", collation: "utf8mb4_bin"
249
259
  end
250
260
  end
251
261
  ```
data/Rakefile CHANGED
@@ -50,7 +50,7 @@ namespace "test" do
50
50
  echo \"gem 'irb', :group => :development\") >> Gemfile"
51
51
  sh "echo '' > app/models/.gitignore" # because git reset --hard would rm the dir
52
52
  rm ".gitignore" # we need to reset everything in a testapp
53
- sh "git init && git add . && git commit -m \"initial commit\""
53
+ sh "git init && git add . && git commit -nm \"initial commit\""
54
54
  sh "rake db:create"
55
55
  puts "The testapp has been created in '#{TESTAPP_PATH}'"
56
56
  else
@@ -3,7 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "bundler", "< 2"
7
6
  gem "climate_control", "~> 0.2"
8
7
  gem "pry"
9
8
  gem "pry-byebug"
@@ -3,7 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "bundler", "< 2"
7
6
  gem "climate_control", "~> 0.2"
8
7
  gem "pry"
9
8
  gem "pry-byebug"
@@ -3,8 +3,9 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "bundler", "< 2"
7
6
  gem "climate_control", "~> 0.2"
7
+ gem "mail"
8
+ gem "net-smtp"
8
9
  gem "pry"
9
10
  gem "pry-byebug"
10
11
  gem "rails", "~> 6.1"
@@ -3,8 +3,9 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "bundler", "< 2"
7
6
  gem "climate_control", "~> 0.2"
7
+ gem "mail"
8
+ gem "net-smtp"
8
9
  gem "pry"
9
10
  gem "pry-byebug"
10
11
  gem "rails", "~> 6.1"
@@ -16,7 +16,7 @@ module DeclareSchema
16
16
  EOS
17
17
 
18
18
  class << self
19
- def run(gem, args, version, gemfile_options = {})
19
+ def run(gem, args, version, **gemfile_options)
20
20
  command = args.shift
21
21
 
22
22
  case command
@@ -12,7 +12,7 @@ module DeclareSchema
12
12
  end
13
13
  end
14
14
 
15
- def initialize(model, options = {})
15
+ def initialize(model, **options)
16
16
  @model = model
17
17
  @options = options
18
18
  end
@@ -29,7 +29,7 @@ module DeclareSchema
29
29
  end
30
30
 
31
31
  def field(name, type, *args, **options)
32
- @model.declare_field(name, type, *(args + [@options.merge(options)]))
32
+ @model.declare_field(name, type, *args, **@options.merge(options))
33
33
  end
34
34
 
35
35
  # TODO: make [:required] just another option. Either 'required: true] or 'optional: false'?
@@ -9,24 +9,6 @@ module DeclareSchema
9
9
  module Macros
10
10
  attr_reader :_table_options
11
11
 
12
- def fields(table_options = {}, &block)
13
- # Any model that calls 'fields' gets DeclareSchema::Model behavior
14
- DeclareSchema::Model.mix_in(self)
15
-
16
- @include_in_migration = true
17
- @_table_options = table_options
18
-
19
- if block
20
- dsl = DeclareSchema::FieldDeclarationDsl.new(self)
21
- if block.arity == 1
22
- yield dsl
23
- else
24
- dsl.instance_eval(&block)
25
- end
26
- end
27
- end
28
- deprecate :fields, deprecator: ActiveSupport::Deprecation.new('1.0', 'DeclareSchema')
29
-
30
12
  def declare_schema(default_schema: true, **table_options, &block)
31
13
  # Any model that calls 'fields' gets DeclareSchema::Model behavior
32
14
  DeclareSchema::Model.mix_in(self)
@@ -12,7 +12,7 @@ module DeclareSchema
12
12
  end
13
13
  end
14
14
 
15
- def initialize(model, options = {})
15
+ def initialize(model, **options)
16
16
  @model = model
17
17
  @options = options
18
18
  end
@@ -29,11 +29,11 @@ module DeclareSchema
29
29
  end
30
30
 
31
31
  def field(name, type, *args, **options)
32
- @model.declare_field(name, type, *[*args, @options.merge(options)])
32
+ @model.declare_field(name, type, *args, **@options.merge(options))
33
33
  end
34
34
 
35
- def method_missing(name, *args)
36
- field(name, *args)
35
+ def method_missing(name, *args, **options)
36
+ field(name, *args, **options)
37
37
  end
38
38
  end
39
39
  end