declare_schema 0.14.3 → 1.0.2
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/.github/CODEOWNERS +1 -0
- data/.github/workflows/declare_schema_build.yml +22 -23
- data/.ruby-version +1 -1
- data/Appraisals +8 -0
- data/CHANGELOG.md +23 -4
- data/Gemfile +3 -2
- data/Gemfile.lock +107 -77
- data/README.md +18 -8
- data/Rakefile +1 -1
- data/gemfiles/rails_5_mysql.gemfile +0 -1
- data/gemfiles/rails_5_sqlite.gemfile +0 -1
- data/gemfiles/rails_6_mysql.gemfile +2 -1
- data/gemfiles/rails_6_sqlite.gemfile +2 -1
- data/lib/declare_schema/command.rb +1 -1
- data/lib/declare_schema/dsl.rb +1 -1
- data/lib/declare_schema/extensions/active_record/fields_declaration.rb +0 -18
- data/lib/declare_schema/field_declaration_dsl.rb +4 -4
- data/lib/declare_schema/model/foreign_key_definition.rb +2 -2
- data/lib/declare_schema/model/index_definition.rb +2 -2
- data/lib/declare_schema/model/table_options_definition.rb +2 -2
- data/lib/declare_schema/model.rb +9 -9
- data/lib/declare_schema/schema_change/all.rb +1 -0
- data/lib/declare_schema/version.rb +1 -1
- data/lib/generators/declare_schema/migration/migrator.rb +6 -6
- data/spec/lib/declare_schema/field_declaration_dsl_spec.rb +0 -24
- data/spec/lib/declare_schema/interactive_primary_key_spec.rb +0 -67
- data/spec/lib/declare_schema/migration_generator_spec.rb +11 -1176
- data/spec/lib/declare_schema/model/column_spec.rb +1 -28
- data/spec/lib/declare_schema/model/foreign_key_definition_spec.rb +1 -94
- data/spec/lib/declare_schema/model/index_definition_spec.rb +0 -109
- data/spec/lib/declare_schema/model/table_options_definition_spec.rb +2 -65
- data/spec/spec_helper.rb +1 -1
- metadata +7 -7
- data/.github/dependabot.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53f77b255392ad9338faad2f2488c3ae34a134c6687cbce5e42d74d33fd2e099
|
4
|
+
data.tar.gz: f07a30238d79d7d8e4194f28cd6d8f3979a9d40ec326ef93f47f76b125a894c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa62f18456e37ab3e809ee1099ee8aa7513dee715f3fd7fafbfb3b56d1f91e5d13cdd31b6d95395f9da46cfa33ff200ea52bd8a57d53416f1909b8ad207d19b9
|
7
|
+
data.tar.gz: 29be47457d43fe9f1b9f58da7bc8865e0780d172667464af25afa62923e9841439f4c4662cb3e1a89f2eee43944779410602c52be3398a61334afbd6ca993d3a
|
data/.github/CODEOWNERS
ADDED
@@ -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: [
|
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
|
-
-
|
20
|
-
|
21
|
-
-
|
22
|
-
|
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
|
-
-
|
34
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
55
|
+
- run: bundle exec rake test:all
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
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,22 @@ 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.2] - 2022-07-18
|
8
|
+
### Fixed
|
9
|
+
- Fixed a bug where `SchemaChange::ColumnRemove` was not loaded and causing an exception to raise
|
10
|
+
when a column was being removed during migration generation
|
11
|
+
|
12
|
+
## [1.0.1] - 2022-07-12
|
13
|
+
### Fixed
|
14
|
+
- Remove lingering usage of `fallback_find_primary_key` method that was removed in `0.14.0`
|
15
|
+
|
16
|
+
## [1.0.0] - 2022-03-28
|
17
|
+
### Added
|
18
|
+
- Added support for Ruby 3+
|
19
|
+
|
20
|
+
### Removed
|
21
|
+
- Removed deprecated `fields` block declaration
|
22
|
+
|
7
23
|
## [0.14.3] - 2021-09-01
|
8
24
|
### Fixed
|
9
25
|
- Fixed more Ruby 2.7 warnings about needing `**options` when calling a method that has `**options` in its signature.
|
@@ -18,7 +34,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
18
34
|
|
19
35
|
## [0.14.0] - 2021-08-10
|
20
36
|
### Removed
|
21
|
-
- Dropped support for Rails versions less than 5.
|
37
|
+
- Dropped support for Rails versions less than 5.
|
22
38
|
|
23
39
|
## [0.13.2] - 2021-08-04
|
24
40
|
### Fixed
|
@@ -55,7 +71,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
55
71
|
The migration will be run if `--migrate` is passed; otherwise, the migrate command will be displayed to be run later.
|
56
72
|
### Added
|
57
73
|
- Added the new configuration option `DeclareSchema.@db_migrate_command =`.
|
58
|
-
### Fixed
|
74
|
+
### Fixed
|
59
75
|
- Fixed bug where foreign key constraint names are not globally unique
|
60
76
|
|
61
77
|
## [0.10.1] - 2021-03-18
|
@@ -109,7 +125,7 @@ i.e. `declare schema { string :title }`. Otherwise, there is no difference betwe
|
|
109
125
|
### Fixed
|
110
126
|
- Fixed a bug in migration generation caused by `DeclareSchema::Migration#create_constraints`
|
111
127
|
calling `DeclareSchema::Model::ForeignKeyDefinition#to_add_statement` with unused parameters.
|
112
|
-
|
128
|
+
|
113
129
|
- Fixed a bug in `DeclareSchema::Migration#remove_foreign_key` where special characters would not be quoted properly.
|
114
130
|
|
115
131
|
## [0.6.2] - 2021-01-06
|
@@ -134,7 +150,7 @@ because all of the existing primary key columns are being removed.
|
|
134
150
|
- FieldSpec#initialize interface now includes `position` keyword argument and `**options` hash.
|
135
151
|
|
136
152
|
### Fixed
|
137
|
-
- Fixed cycle in which FieldSpec#initialize was calling `model.field_specs`
|
153
|
+
- Fixed cycle in which FieldSpec#initialize was calling `model.field_specs`
|
138
154
|
|
139
155
|
### Changed
|
140
156
|
- Changed ci support from Travis to Github Workflow
|
@@ -208,6 +224,9 @@ using the appropriate Rails configuration attributes.
|
|
208
224
|
### Added
|
209
225
|
- Initial version from https://github.com/Invoca/hobo_fields v4.1.0.
|
210
226
|
|
227
|
+
[1.0.2]: https://github.com/Invoca/declare_schema/compare/v1.0.1...v1.0.2
|
228
|
+
[1.0.1]: https://github.com/Invoca/declare_schema/compare/v1.0.0...v1.0.1
|
229
|
+
[1.0.0]: https://github.com/Invoca/declare_schema/compare/v0.14.3...v1.0.0
|
211
230
|
[0.14.3]: https://github.com/Invoca/declare_schema/compare/v0.14.2...v0.14.3
|
212
231
|
[0.14.2]: https://github.com/Invoca/declare_schema/compare/v0.14.1...v0.14.2
|
213
232
|
[0.14.1]: https://github.com/Invoca/declare_schema/compare/v0.14.0...v0.14.1
|
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', '~>
|
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.
|
4
|
+
declare_schema (1.0.2)
|
5
5
|
rails (>= 5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (
|
11
|
-
actionpack (=
|
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
|
-
|
15
|
-
actionpack (=
|
16
|
-
|
17
|
-
|
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 (
|
21
|
-
actionview (=
|
22
|
-
activesupport (=
|
23
|
-
rack (~> 2.0, >= 2.0.
|
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
|
27
|
-
|
28
|
-
|
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.
|
33
|
-
activejob (
|
34
|
-
activesupport (=
|
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 (
|
37
|
-
activesupport (=
|
38
|
-
activerecord (
|
39
|
-
activemodel (=
|
40
|
-
activesupport (=
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
activerecord (=
|
45
|
-
|
46
|
-
|
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 (>=
|
49
|
-
minitest (
|
50
|
-
tzinfo (~>
|
51
|
-
|
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.
|
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.
|
69
|
-
activesupport (>=
|
70
|
-
i18n (1.
|
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.
|
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.
|
99
|
+
marcel (1.0.2)
|
81
100
|
method_source (1.0.0)
|
82
|
-
mini_mime (1.1.
|
83
|
-
mini_portile2 (2.
|
84
|
-
minitest (5.
|
101
|
+
mini_mime (1.1.2)
|
102
|
+
mini_portile2 (2.8.0)
|
103
|
+
minitest (5.15.0)
|
85
104
|
msgpack (1.4.2)
|
86
|
-
|
87
|
-
|
88
|
-
|
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.
|
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 (
|
104
|
-
actioncable (=
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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.
|
147
|
+
rails-html-sanitizer (1.4.2)
|
120
148
|
loofah (~> 2.3)
|
121
|
-
railties (
|
122
|
-
actionpack (=
|
123
|
-
activesupport (=
|
149
|
+
railties (6.1.5)
|
150
|
+
actionpack (= 6.1.5)
|
151
|
+
activesupport (= 6.1.5)
|
124
152
|
method_source
|
125
|
-
rake (>=
|
126
|
-
thor (
|
153
|
+
rake (>= 12.2)
|
154
|
+
thor (~> 1.0)
|
127
155
|
rainbow (3.0.0)
|
128
|
-
rake (13.0.
|
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.
|
190
|
+
sprockets (4.0.3)
|
163
191
|
concurrent-ruby (~> 1.0)
|
164
192
|
rack (> 1, < 3)
|
165
|
-
sprockets-rails (3.
|
166
|
-
actionpack (>=
|
167
|
-
activesupport (>=
|
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
|
171
|
-
|
172
|
-
tzinfo (
|
173
|
-
|
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.
|
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 (~>
|
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
|
-
|
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
|
12
|
-
ticker_symbol
|
13
|
-
|
14
|
-
comments
|
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
|
-
|
228
|
-
content
|
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
|
-
|
248
|
-
context
|
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 -
|
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
|
data/lib/declare_schema/dsl.rb
CHANGED
@@ -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, *
|
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
|
@@ -10,7 +10,7 @@ module DeclareSchema
|
|
10
10
|
attr_reader :constraint_name, :model, :foreign_key, :foreign_key_name, :parent_table_name, :child_table_name, :options, :on_delete_cascade
|
11
11
|
|
12
12
|
|
13
|
-
def initialize(model, foreign_key, options
|
13
|
+
def initialize(model, foreign_key, **options)
|
14
14
|
@model = model
|
15
15
|
@foreign_key = foreign_key.to_s.presence
|
16
16
|
@options = options
|
@@ -38,7 +38,7 @@ module DeclareSchema
|
|
38
38
|
}
|
39
39
|
options[:dependent] = :delete if fkc['ON DELETE CASCADE']
|
40
40
|
|
41
|
-
new(model, foreign_key, options)
|
41
|
+
new(model, foreign_key, **options)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|