declare_schema 0.13.0 → 0.14.1
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 +0 -4
- data/.ruby-version +1 -1
- data/Appraisals +0 -10
- data/CHANGELOG.md +21 -1
- data/Gemfile.lock +52 -54
- data/declare_schema.gemspec +1 -1
- data/lib/declare_schema/model/column.rb +3 -11
- data/lib/declare_schema/model/index_definition.rb +0 -26
- data/lib/declare_schema/model.rb +4 -16
- data/lib/declare_schema/version.rb +1 -1
- data/lib/declare_schema.rb +1 -6
- data/lib/generators/declare_schema/migration/migration_generator.rb +2 -15
- data/lib/generators/declare_schema/migration/migrator.rb +8 -14
- data/lib/generators/declare_schema/migration/templates/migration.rb.erb +3 -3
- data/spec/lib/declare_schema/field_spec_spec.rb +2 -12
- data/spec/lib/declare_schema/generator_spec.rb +1 -15
- data/spec/lib/declare_schema/interactive_primary_key_spec.rb +2 -2
- data/spec/lib/declare_schema/migration_generator_spec.rb +64 -79
- data/spec/lib/declare_schema/model/column_spec.rb +11 -16
- data/spec/lib/declare_schema/model/index_definition_spec.rb +0 -20
- data/spec/spec_helper.rb +1 -5
- metadata +5 -7
- data/gemfiles/rails_4_mysql.gemfile +0 -22
- data/gemfiles/rails_4_sqlite.gemfile +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd53a96307dce4b6f8c1ab3372820991af20afdb91f78dc28a022ccd4edc6867
|
4
|
+
data.tar.gz: b8a2a17a17b6df4fd4f6b5915386734cdc439613a65b60e490dd5d906fd4e457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64cf2d70ecb330394607241f4a4094c37ad0ee1291df3b1ce8e652f82c8e1ebdd96fc0adffa48bdcfe2e641a8be0197541cce19d46b89460aef3b656718a4d5b
|
7
|
+
data.tar.gz: afcdcc1e94a8504797d9e5b986009d7f932e9822e717ce33fb4588a53039ae9e53a389642c98c0be38b3c922c10de1314fba663f1a9badc739fdb69357772e24
|
@@ -11,15 +11,11 @@ jobs:
|
|
11
11
|
matrix:
|
12
12
|
ruby: [ 2.4.5, 2.5.8, 2.6.5, 2.7.1 ]
|
13
13
|
gemfile:
|
14
|
-
- gemfiles/rails_4_mysql.gemfile
|
15
|
-
- gemfiles/rails_4_sqlite.gemfile
|
16
14
|
- gemfiles/rails_5_mysql.gemfile
|
17
15
|
- gemfiles/rails_5_sqlite.gemfile
|
18
16
|
- gemfiles/rails_6_mysql.gemfile
|
19
17
|
- gemfiles/rails_6_sqlite.gemfile
|
20
18
|
exclude:
|
21
|
-
- { gemfile: gemfiles/rails_4_mysql.gemfile, ruby: 2.7.1 }
|
22
|
-
- { gemfile: gemfiles/rails_4_sqlite.gemfile, ruby: 2.7.1 }
|
23
19
|
- { gemfile: gemfiles/rails_5_mysql.gemfile, ruby: 2.4.5 }
|
24
20
|
- { gemfile: gemfiles/rails_5_sqlite.gemfile, ruby: 2.4.5 }
|
25
21
|
- { gemfile: gemfiles/rails_6_mysql.gemfile, ruby: 2.4.5 }
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.0
|
data/Appraisals
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'rails-4-sqlite' do
|
4
|
-
gem 'rails', '~> 4.2'
|
5
|
-
gem 'sqlite3', '~> 1.3.0'
|
6
|
-
end
|
7
|
-
|
8
|
-
appraise 'rails-4-mysql' do
|
9
|
-
gem 'rails', '~> 4.2'
|
10
|
-
gem 'mysql2'
|
11
|
-
end
|
12
|
-
|
13
3
|
appraise 'rails-5-sqlite' do
|
14
4
|
gem 'rails', '~> 5.2'
|
15
5
|
gem 'sqlite3'
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,24 @@ 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
|
-
## [0.
|
7
|
+
## [0.14.1] - 2021-09-01
|
8
|
+
### Fixed
|
9
|
+
- Fixed Ruby 2.7 warning about needing `**options` when calling a method that has `**options` in its signature.
|
10
|
+
|
11
|
+
## [0.14.0] - 2021-08-10
|
12
|
+
### Removed
|
13
|
+
- Dropped support for Rails versions less than 5.
|
14
|
+
|
15
|
+
## [0.13.2] - 2021-08-04
|
16
|
+
### Fixed
|
17
|
+
- Fixed issue with disable_auto_increment support for new tables.
|
18
|
+
|
19
|
+
## [0.13.1] - 2021-08-02
|
20
|
+
### Fixed
|
21
|
+
- Fixed migration file indentation bug in Rails 5 where the first line was indented an extra 4 characters.
|
22
|
+
And fixed the longstanding triple-spacing bug to use double spacing.
|
23
|
+
|
24
|
+
## [0.13.0] - 2021-06-11
|
8
25
|
### Added
|
9
26
|
- Added support for `default_schema` block to apply a default schema to every model, unless disabled for that model with `default_schema: false`.
|
10
27
|
|
@@ -183,6 +200,9 @@ using the appropriate Rails configuration attributes.
|
|
183
200
|
### Added
|
184
201
|
- Initial version from https://github.com/Invoca/hobo_fields v4.1.0.
|
185
202
|
|
203
|
+
[0.14.1]: https://github.com/Invoca/declare_schema/compare/v0.14.0...v0.14.1
|
204
|
+
[0.14.0]: https://github.com/Invoca/declare_schema/compare/v0.13.1...v0.14.0
|
205
|
+
[0.13.1]: https://github.com/Invoca/declare_schema/compare/v0.13.0...v0.13.1
|
186
206
|
[0.13.0]: https://github.com/Invoca/declare_schema/compare/v0.12.1...v0.13.0
|
187
207
|
[0.12.1]: https://github.com/Invoca/declare_schema/compare/v0.12.0...v0.12.1
|
188
208
|
[0.12.0]: https://github.com/Invoca/declare_schema/compare/v0.11.1...v0.12.0
|
data/Gemfile.lock
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
declare_schema (0.
|
5
|
-
rails (>=
|
4
|
+
declare_schema (0.14.1)
|
5
|
+
rails (>= 5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (5.2.
|
11
|
-
actionpack (= 5.2.
|
10
|
+
actioncable (5.2.6)
|
11
|
+
actionpack (= 5.2.6)
|
12
12
|
nio4r (~> 2.0)
|
13
13
|
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailer (5.2.
|
15
|
-
actionpack (= 5.2.
|
16
|
-
actionview (= 5.2.
|
17
|
-
activejob (= 5.2.
|
14
|
+
actionmailer (5.2.6)
|
15
|
+
actionpack (= 5.2.6)
|
16
|
+
actionview (= 5.2.6)
|
17
|
+
activejob (= 5.2.6)
|
18
18
|
mail (~> 2.5, >= 2.5.4)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.2.
|
21
|
-
actionview (= 5.2.
|
22
|
-
activesupport (= 5.2.
|
20
|
+
actionpack (5.2.6)
|
21
|
+
actionview (= 5.2.6)
|
22
|
+
activesupport (= 5.2.6)
|
23
23
|
rack (~> 2.0, >= 2.0.8)
|
24
24
|
rack-test (>= 0.6.3)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.2.
|
28
|
-
activesupport (= 5.2.
|
27
|
+
actionview (5.2.6)
|
28
|
+
activesupport (= 5.2.6)
|
29
29
|
builder (~> 3.1)
|
30
30
|
erubi (~> 1.4)
|
31
31
|
rails-dom-testing (~> 2.0)
|
32
32
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.2.
|
34
|
-
activesupport (= 5.2.
|
33
|
+
activejob (5.2.6)
|
34
|
+
activesupport (= 5.2.6)
|
35
35
|
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.2.
|
37
|
-
activesupport (= 5.2.
|
38
|
-
activerecord (5.2.
|
39
|
-
activemodel (= 5.2.
|
40
|
-
activesupport (= 5.2.
|
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
41
|
arel (>= 9.0)
|
42
|
-
activestorage (5.2.
|
43
|
-
actionpack (= 5.2.
|
44
|
-
activerecord (= 5.2.
|
45
|
-
marcel (~> 0.
|
46
|
-
activesupport (5.2.
|
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)
|
47
47
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
48
|
i18n (>= 0.7, < 2)
|
49
49
|
minitest (~> 5.1)
|
@@ -60,33 +60,31 @@ GEM
|
|
60
60
|
byebug (11.1.3)
|
61
61
|
climate_control (0.2.0)
|
62
62
|
coderay (1.1.3)
|
63
|
-
concurrent-ruby (1.1.
|
63
|
+
concurrent-ruby (1.1.9)
|
64
64
|
crass (1.0.6)
|
65
65
|
diff-lcs (1.4.4)
|
66
66
|
erubi (1.10.0)
|
67
|
-
ffi (1.
|
67
|
+
ffi (1.15.1)
|
68
68
|
globalid (0.4.2)
|
69
69
|
activesupport (>= 4.2.0)
|
70
|
-
i18n (1.8.
|
70
|
+
i18n (1.8.10)
|
71
71
|
concurrent-ruby (~> 1.0)
|
72
|
-
listen (3.
|
72
|
+
listen (3.5.1)
|
73
73
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
74
74
|
rb-inotify (~> 0.9, >= 0.9.10)
|
75
|
-
loofah (2.
|
75
|
+
loofah (2.10.0)
|
76
76
|
crass (~> 1.0.2)
|
77
77
|
nokogiri (>= 1.5.9)
|
78
78
|
mail (2.7.1)
|
79
79
|
mini_mime (>= 0.1.1)
|
80
|
-
marcel (0.
|
81
|
-
mimemagic (~> 0.3.2)
|
80
|
+
marcel (1.0.1)
|
82
81
|
method_source (1.0.0)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
minitest (5.14.3)
|
82
|
+
mini_mime (1.1.0)
|
83
|
+
mini_portile2 (2.5.3)
|
84
|
+
minitest (5.14.4)
|
87
85
|
msgpack (1.4.2)
|
88
|
-
nio4r (2.5.
|
89
|
-
nokogiri (1.11.
|
86
|
+
nio4r (2.5.7)
|
87
|
+
nokogiri (1.11.7)
|
90
88
|
mini_portile2 (~> 2.5.0)
|
91
89
|
racc (~> 1.4)
|
92
90
|
parallel (1.19.2)
|
@@ -102,33 +100,33 @@ GEM
|
|
102
100
|
rack (2.2.3)
|
103
101
|
rack-test (1.1.0)
|
104
102
|
rack (>= 1.0, < 3)
|
105
|
-
rails (5.2.
|
106
|
-
actioncable (= 5.2.
|
107
|
-
actionmailer (= 5.2.
|
108
|
-
actionpack (= 5.2.
|
109
|
-
actionview (= 5.2.
|
110
|
-
activejob (= 5.2.
|
111
|
-
activemodel (= 5.2.
|
112
|
-
activerecord (= 5.2.
|
113
|
-
activestorage (= 5.2.
|
114
|
-
activesupport (= 5.2.
|
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)
|
115
113
|
bundler (>= 1.3.0)
|
116
|
-
railties (= 5.2.
|
114
|
+
railties (= 5.2.6)
|
117
115
|
sprockets-rails (>= 2.0.0)
|
118
116
|
rails-dom-testing (2.0.3)
|
119
117
|
activesupport (>= 4.2.0)
|
120
118
|
nokogiri (>= 1.6)
|
121
119
|
rails-html-sanitizer (1.3.0)
|
122
120
|
loofah (~> 2.3)
|
123
|
-
railties (5.2.
|
124
|
-
actionpack (= 5.2.
|
125
|
-
activesupport (= 5.2.
|
121
|
+
railties (5.2.6)
|
122
|
+
actionpack (= 5.2.6)
|
123
|
+
activesupport (= 5.2.6)
|
126
124
|
method_source
|
127
125
|
rake (>= 0.8.7)
|
128
126
|
thor (>= 0.19.0, < 2.0)
|
129
127
|
rainbow (3.0.0)
|
130
128
|
rake (13.0.3)
|
131
|
-
rb-fsevent (0.
|
129
|
+
rb-fsevent (0.11.0)
|
132
130
|
rb-inotify (0.10.1)
|
133
131
|
ffi (~> 1.0)
|
134
132
|
regexp_parser (1.8.0)
|
@@ -174,7 +172,7 @@ GEM
|
|
174
172
|
tzinfo (1.2.9)
|
175
173
|
thread_safe (~> 0.1)
|
176
174
|
unicode-display_width (1.7.0)
|
177
|
-
websocket-driver (0.7.
|
175
|
+
websocket-driver (0.7.4)
|
178
176
|
websocket-extensions (>= 0.1.0)
|
179
177
|
websocket-extensions (0.1.5)
|
180
178
|
yard (0.9.26)
|
data/declare_schema.gemspec
CHANGED
@@ -52,17 +52,9 @@ module DeclareSchema
|
|
52
52
|
|
53
53
|
def deserialize_default_value(column, type, default_value)
|
54
54
|
type or raise ArgumentError, "must pass type; got #{type.inspect}"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
# TODO: Delete this Rails 4 support ASAP! This could be wrong, since it's using the type of the old column...which
|
59
|
-
# might be getting migrated to a new type. We should be using just type as below. -Colin
|
60
|
-
column.type_cast_from_database(default_value)
|
61
|
-
else
|
62
|
-
cast_type = ActiveRecord::Base.connection.send(:lookup_cast_type, type.to_s) or
|
63
|
-
raise "cast_type not found for #{type}"
|
64
|
-
cast_type.deserialize(default_value)
|
65
|
-
end
|
55
|
+
cast_type = ActiveRecord::Base.connection.send(:lookup_cast_type, type.to_s) or
|
56
|
+
raise "cast_type not found for #{type}"
|
57
|
+
cast_type.deserialize(default_value)
|
66
58
|
end
|
67
59
|
|
68
60
|
# Normalizes schema attributes for the given database adapter name.
|
@@ -63,32 +63,6 @@ module DeclareSchema
|
|
63
63
|
def index_name(columns)
|
64
64
|
"on_#{Array(columns).join("_and_")}"
|
65
65
|
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
# This is the old approach which is still needed for MySQL in Rails 4 and SQLite
|
70
|
-
def fallback_find_primary_key(model, table)
|
71
|
-
ActiveRecord::Base.connection.class.name.match?(/SQLite3Adapter/) || ActiveSupport::VERSION::MAJOR < 5 or return nil
|
72
|
-
|
73
|
-
connection = model.connection.dup
|
74
|
-
|
75
|
-
class << connection # defeat Rails MySQL driver code that skips the primary key by changing its name to a symbol
|
76
|
-
def each_hash(result)
|
77
|
-
super do |hash|
|
78
|
-
if hash[:Key_name] == PRIMARY_KEY_NAME
|
79
|
-
hash[:Key_name] = PRIMARY_KEY_NAME.to_sym
|
80
|
-
end
|
81
|
-
yield hash
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
if (pk_index = connection.indexes(table).find { |index| index.name.to_s == PRIMARY_KEY_NAME })
|
87
|
-
Array(pk_index.columns)
|
88
|
-
elsif model.connection.columns(table).any? { |col| col.name == 'id' }
|
89
|
-
['id']
|
90
|
-
end
|
91
|
-
end
|
92
66
|
end
|
93
67
|
|
94
68
|
def primary_key?
|
data/lib/declare_schema/model.rb
CHANGED
@@ -131,11 +131,7 @@ module DeclareSchema
|
|
131
131
|
|
132
132
|
fk_options[:dependent] = options.delete(:far_end_dependent) if options.has_key?(:far_end_dependent)
|
133
133
|
|
134
|
-
|
135
|
-
super
|
136
|
-
else
|
137
|
-
super(name, scope, options.except(:optional))
|
138
|
-
end
|
134
|
+
super
|
139
135
|
|
140
136
|
refl = reflections[name.to_s] or raise "Couldn't find reflection #{name} in #{reflections.keys}"
|
141
137
|
fkey = refl.foreign_key or raise "Couldn't find foreign_key for #{name} in #{refl.inspect}"
|
@@ -156,7 +152,7 @@ module DeclareSchema
|
|
156
152
|
end
|
157
153
|
end
|
158
154
|
|
159
|
-
declare_field(fkey.to_sym, :bigint, fkey_id_column_options)
|
155
|
+
declare_field(fkey.to_sym, :bigint, **fkey_id_column_options)
|
160
156
|
|
161
157
|
if refl.options[:polymorphic]
|
162
158
|
foreign_type = options[:foreign_type] || "#{name}_type"
|
@@ -190,12 +186,6 @@ module DeclareSchema
|
|
190
186
|
end
|
191
187
|
end
|
192
188
|
|
193
|
-
if ::ActiveSupport::VERSION::MAJOR < 5
|
194
|
-
def primary_key
|
195
|
-
super || 'id'
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
189
|
# returns the primary key (String) as declared with primary_key =
|
200
190
|
# unlike the `primary_key` method, DOES NOT query the database to find the actual primary key in use right now
|
201
191
|
# if no explicit primary key set, returns the _default_declared_primary_key
|
@@ -224,7 +214,7 @@ module DeclareSchema
|
|
224
214
|
# Declares the "foo_type" field that accompanies the "foo_id"
|
225
215
|
# field for a polymorphic belongs_to
|
226
216
|
def _declare_polymorphic_type_field(foreign_type, column_options)
|
227
|
-
declare_field(foreign_type, :string, column_options.merge(limit: 255))
|
217
|
+
declare_field(foreign_type, :string, **column_options.merge(limit: 255))
|
228
218
|
# FIXME: Before declare_schema was extracted, this used to now do:
|
229
219
|
# never_show(type_col)
|
230
220
|
# That needs doing somewhere
|
@@ -268,10 +258,8 @@ module DeclareSchema
|
|
268
258
|
ActiveRecord::Coders::JSON
|
269
259
|
elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
|
270
260
|
class_name_or_coder
|
271
|
-
|
261
|
+
else
|
272
262
|
ActiveRecord::Coders::YAMLColumn.new(attr_name, class_name_or_coder)
|
273
|
-
else
|
274
|
-
ActiveRecord::Coders::YAMLColumn.new(class_name_or_coder)
|
275
263
|
end
|
276
264
|
|
277
265
|
if default == coder.load(nil)
|
data/lib/declare_schema.rb
CHANGED
@@ -28,12 +28,7 @@ module DeclareSchema
|
|
28
28
|
@default_null = false
|
29
29
|
@default_generate_foreign_keys = true
|
30
30
|
@default_generate_indexing = true
|
31
|
-
@db_migrate_command =
|
32
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
33
|
-
"bundle exec rake db:migrate"
|
34
|
-
else
|
35
|
-
"bundle exec rails db:migrate"
|
36
|
-
end
|
31
|
+
@db_migrate_command = "bundle exec rails db:migrate"
|
37
32
|
|
38
33
|
class << self
|
39
34
|
attr_reader :default_charset, :default_collation, :default_text_limit, :default_string_limit, :default_null,
|
@@ -83,11 +83,7 @@ module DeclareSchema
|
|
83
83
|
if options[:migrate]
|
84
84
|
say db_migrate_command
|
85
85
|
bare_rails_command = db_migrate_command.sub(/\Abundle exec +/, '').sub(/\Arake +|rails +/, '')
|
86
|
-
|
87
|
-
rake(bare_rails_command)
|
88
|
-
else
|
89
|
-
rails_command(bare_rails_command)
|
90
|
-
end
|
86
|
+
rails_command(bare_rails_command)
|
91
87
|
else
|
92
88
|
say "\nNot running migration since --migrate not given. When you are ready, run:\n\n #{db_migrate_command}\n\n"
|
93
89
|
end
|
@@ -97,24 +93,15 @@ module DeclareSchema
|
|
97
93
|
|
98
94
|
private
|
99
95
|
|
100
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
101
|
-
def indent(string, columns)
|
102
|
-
whitespace = ' ' * columns
|
103
|
-
string.gsub("\n", "\n#{whitespace}").gsub(/ +\n/, "\n")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
96
|
def migrations_pending?
|
108
97
|
migrations = case ActiveSupport::VERSION::MAJOR
|
109
|
-
when 4
|
110
|
-
ActiveRecord::Migrator.migrations('db/migrate')
|
111
98
|
when 5
|
112
99
|
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths).migrations
|
113
100
|
else
|
114
101
|
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths, ActiveRecord::SchemaMigration).migrations
|
115
102
|
end
|
116
103
|
pending_migrations = case ActiveSupport::VERSION::MAJOR
|
117
|
-
when
|
104
|
+
when 5
|
118
105
|
ActiveRecord::Migrator.new(:up, migrations).pending_migrations
|
119
106
|
else
|
120
107
|
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration).pending_migrations
|
@@ -226,7 +226,9 @@ module Generators
|
|
226
226
|
|
227
227
|
primary_key_definition =
|
228
228
|
if disable_auto_increment
|
229
|
-
[:integer, :id, limit: 8, auto_increment: false, primary_key: true]
|
229
|
+
[[:integer, :id, limit: 8, auto_increment: false, primary_key: true]]
|
230
|
+
else
|
231
|
+
[]
|
230
232
|
end
|
231
233
|
|
232
234
|
field_definitions = model.field_specs.values.sort_by(&:position).map do |f|
|
@@ -237,7 +239,7 @@ module Generators
|
|
237
239
|
table_options = create_table_options(model, disable_auto_increment)
|
238
240
|
|
239
241
|
table_add = ::DeclareSchema::SchemaChange::TableAdd.new(t,
|
240
|
-
|
242
|
+
primary_key_definition + field_definitions,
|
241
243
|
table_options,
|
242
244
|
sql_options: table_options_definition.settings)
|
243
245
|
[
|
@@ -299,7 +301,7 @@ module Generators
|
|
299
301
|
up = migration_commands.map(&:up ).select(&:present?)
|
300
302
|
down = migration_commands.map(&:down).select(&:present?).reverse
|
301
303
|
|
302
|
-
[up * "\n
|
304
|
+
[up * "\n", down * "\n"]
|
303
305
|
end
|
304
306
|
|
305
307
|
def create_table_options(model, disable_auto_increment)
|
@@ -487,11 +489,7 @@ module Generators
|
|
487
489
|
parent_columns = connection.columns(parent_table) rescue []
|
488
490
|
pk_limit =
|
489
491
|
if (pk_column = parent_columns.find { |column| column.name.to_s == "id" }) # right now foreign keys assume id is the target
|
490
|
-
|
491
|
-
pk_column.cast_type.limit
|
492
|
-
else
|
493
|
-
pk_column.limit
|
494
|
-
end
|
492
|
+
pk_column.limit
|
495
493
|
else
|
496
494
|
8
|
497
495
|
end
|
@@ -553,12 +551,8 @@ module Generators
|
|
553
551
|
end
|
554
552
|
end
|
555
553
|
|
556
|
-
SchemaDumper =
|
557
|
-
|
558
|
-
ActiveRecord::SchemaDumper
|
559
|
-
else
|
560
|
-
ActiveRecord::ConnectionAdapters::SchemaDumper
|
561
|
-
end
|
554
|
+
SchemaDumper = ActiveRecord::ConnectionAdapters::SchemaDumper
|
555
|
+
|
562
556
|
|
563
557
|
def add_table_back(table)
|
564
558
|
dumped_schema_stream = StringIO.new
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class <%= @migration_class_name %> < (
|
1
|
+
class <%= @migration_class_name %> < (ActiveRecord::Migration[4.2])
|
2
2
|
def self.up
|
3
|
-
|
3
|
+
<%= @up.presence or raise "no @up given!" %>
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.down
|
7
|
-
|
7
|
+
<%= @down.presence or raise "no @down given!" %>
|
8
8
|
end
|
9
9
|
end
|
@@ -11,10 +11,6 @@ RSpec.describe DeclareSchema::Model::FieldSpec do
|
|
11
11
|
|
12
12
|
before do
|
13
13
|
load File.expand_path('prepare_testapp.rb', __dir__)
|
14
|
-
|
15
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
16
|
-
allow(col_spec).to receive(:type_cast_from_database, &:itself)
|
17
|
-
end
|
18
14
|
end
|
19
15
|
|
20
16
|
describe '#initialize' do
|
@@ -226,14 +222,8 @@ RSpec.describe DeclareSchema::Model::FieldSpec do
|
|
226
222
|
|
227
223
|
describe '#schema_attributes' do
|
228
224
|
let(:col_spec) do
|
229
|
-
|
230
|
-
|
231
|
-
cast_type = ActiveRecord::Type::Integer.new(limit: 8)
|
232
|
-
ActiveRecord::ConnectionAdapters::Column.new("price", nil, cast_type, "integer(8)", false)
|
233
|
-
else
|
234
|
-
sql_type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: "integer(8)", type: :integer, limit: 8)
|
235
|
-
ActiveRecord::ConnectionAdapters::Column.new("price", nil, sql_type_metadata, false, "adverts")
|
236
|
-
end
|
225
|
+
sql_type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: "integer(8)", type: :integer, limit: 8)
|
226
|
+
ActiveRecord::ConnectionAdapters::Column.new("price", nil, sql_type_metadata, false, "adverts")
|
237
227
|
end
|
238
228
|
|
239
229
|
it 'returns the attributes except name, position, and non-SQL options' do
|
@@ -28,7 +28,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
28
28
|
EOS
|
29
29
|
|
30
30
|
case ActiveSupport::VERSION::MAJOR
|
31
|
-
when
|
31
|
+
when 5
|
32
32
|
expect_test_definition_to_eq('alpha/beta', <<~EOS)
|
33
33
|
require "test_helper"
|
34
34
|
|
@@ -51,20 +51,6 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
case ActiveSupport::VERSION::MAJOR
|
54
|
-
when 4
|
55
|
-
expect_test_fixture_to_eq('alpha/beta', <<~EOS)
|
56
|
-
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
57
|
-
|
58
|
-
# This model initially had no columns defined. If you add columns to the
|
59
|
-
# model remove the '{}' from the fixture names and add the columns immediately
|
60
|
-
# below each fixture, per the syntax in the comments below
|
61
|
-
#
|
62
|
-
one: {}
|
63
|
-
# column: value
|
64
|
-
#
|
65
|
-
two: {}
|
66
|
-
# column: value
|
67
|
-
EOS
|
68
54
|
when 5
|
69
55
|
expect_test_fixture_to_eq('alpha/beta', <<~EOS)
|
70
56
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
@@ -62,7 +62,7 @@ RSpec.describe 'DeclareSchema Migration Generator interactive primary key' do
|
|
62
62
|
ActiveRecord::Base.connection.execute("CREATE TABLE foos (id integer PRIMARY KEY AUTOINCREMENT NOT NULL)")
|
63
63
|
end
|
64
64
|
|
65
|
-
if
|
65
|
+
if !defined?(Mysql2) # TODO TECH-4814 Put this test back for Mysql2
|
66
66
|
# replace custom primary_key
|
67
67
|
class Foo < ActiveRecord::Base
|
68
68
|
fields do
|
@@ -128,7 +128,7 @@ RSpec.describe 'DeclareSchema Migration Generator interactive primary key' do
|
|
128
128
|
ActiveRecord::Base.connection.execute("CREATE TABLE foos (id integer PRIMARY KEY AUTOINCREMENT NOT NULL)")
|
129
129
|
end
|
130
130
|
|
131
|
-
if
|
131
|
+
if !defined?(Mysql2) # TODO TECH-4814 Put this test back for Mysql2
|
132
132
|
# replace custom primary_key
|
133
133
|
class Foo < ActiveRecord::Base
|
134
134
|
declare_schema do
|
@@ -30,7 +30,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
let(:datetime_precision) do
|
33
|
-
if defined?(Mysql2)
|
33
|
+
if defined?(Mysql2)
|
34
34
|
', precision: 0'
|
35
35
|
end
|
36
36
|
end
|
@@ -43,7 +43,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
43
43
|
''
|
44
44
|
end
|
45
45
|
else
|
46
|
-
", id: :integer"
|
46
|
+
", id: :integer"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
let(:lock_version_limit) do
|
@@ -91,16 +91,6 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
91
91
|
ActiveRecord::Migration.class_eval(up)
|
92
92
|
expect(Advert.columns.map(&:name)).to eq(["id", "name"])
|
93
93
|
|
94
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
95
|
-
# Rails 4 drivers don't always create PK properly. Fix that by dropping and recreating.
|
96
|
-
ActiveRecord::Base.connection.execute("drop table adverts")
|
97
|
-
if defined?(Mysql2)
|
98
|
-
ActiveRecord::Base.connection.execute("CREATE TABLE adverts (id integer PRIMARY KEY AUTO_INCREMENT NOT NULL, name varchar(250)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin")
|
99
|
-
else
|
100
|
-
ActiveRecord::Base.connection.execute("CREATE TABLE adverts (id integer PRIMARY KEY AUTOINCREMENT NOT NULL, name varchar(250))")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
94
|
class Advert < ActiveRecord::Base
|
105
95
|
fields do
|
106
96
|
name :string, limit: 250, null: true
|
@@ -803,9 +793,36 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
803
793
|
EOS
|
804
794
|
)
|
805
795
|
|
796
|
+
Advert.connection.schema_cache.clear!
|
797
|
+
Advert.reset_column_information
|
798
|
+
|
806
799
|
nuke_model_class(Advert)
|
807
800
|
ActiveRecord::Base.connection.execute("drop table `adverts`;")
|
808
801
|
|
802
|
+
if !defined?(SQLite3) && ActiveSupport::VERSION::MAJOR >= 5
|
803
|
+
class Advert < ActiveRecord::Base
|
804
|
+
def self.disable_auto_increment
|
805
|
+
true
|
806
|
+
end
|
807
|
+
|
808
|
+
fields do
|
809
|
+
description :text, limit: 250, null: true
|
810
|
+
end
|
811
|
+
end
|
812
|
+
|
813
|
+
up, _ = Generators::DeclareSchema::Migration::Migrator.run.tap do |migrations|
|
814
|
+
expect(migrations).to(
|
815
|
+
migrate_up(<<~EOS.strip)
|
816
|
+
create_table :adverts, id: false, options: "CHARACTER SET utf8mb4 COLLATE utf8mb4_bin" do |t|
|
817
|
+
t.integer :id, limit: 8, auto_increment: false, primary_key: true
|
818
|
+
t.text :description, limit: 255, null: true, charset: "utf8mb4", collation: "utf8mb4_bin"
|
819
|
+
end
|
820
|
+
EOS
|
821
|
+
.and migrate_down("drop_table :adverts")
|
822
|
+
)
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
809
826
|
## DSL
|
810
827
|
|
811
828
|
# The DSL allows lambdas and constants
|
@@ -886,7 +903,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
886
903
|
nuke_model_class(Advertiser)
|
887
904
|
nuke_model_class(Affiliate)
|
888
905
|
end
|
889
|
-
end if !defined?(SQLite3)
|
906
|
+
end if !defined?(SQLite3)
|
890
907
|
|
891
908
|
describe 'serialize' do
|
892
909
|
before do
|
@@ -1073,13 +1090,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
1073
1090
|
end
|
1074
1091
|
|
1075
1092
|
context "for Rails #{ActiveSupport::VERSION::MAJOR}" do
|
1076
|
-
|
1077
|
-
|
1078
|
-
let(:optional_false) { { optional: false } }
|
1079
|
-
else
|
1080
|
-
let(:optional_true) { {} }
|
1081
|
-
let(:optional_false) { {} }
|
1082
|
-
end
|
1093
|
+
let(:optional_true) { { optional: true } }
|
1094
|
+
let(:optional_false) { { optional: false } }
|
1083
1095
|
let(:optional_flag) { { false => optional_false, true => optional_true } }
|
1084
1096
|
|
1085
1097
|
describe 'belongs_to' do
|
@@ -1179,36 +1191,30 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
1179
1191
|
migration_content = File.read(migrations.first)
|
1180
1192
|
first_line = migration_content.split("\n").first
|
1181
1193
|
base_class = first_line.split(' < ').last
|
1182
|
-
expect(base_class).to eq("(
|
1194
|
+
expect(base_class).to eq("(ActiveRecord::Migration[4.2])")
|
1183
1195
|
end
|
1184
1196
|
end
|
1185
1197
|
|
1186
1198
|
context 'Does not generate migrations' do
|
1187
1199
|
it 'for aliased fields bigint -> integer limit 8' do
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
price :bigint
|
1192
|
-
end
|
1200
|
+
class Advert < active_record_base_class.constantize
|
1201
|
+
fields do
|
1202
|
+
price :bigint
|
1193
1203
|
end
|
1204
|
+
end
|
1194
1205
|
|
1195
|
-
|
1196
|
-
|
1197
|
-
migrations = Dir.glob('db/migrate/*declare_schema_migration*.rb')
|
1198
|
-
expect(migrations.size).to eq(1), migrations.inspect
|
1206
|
+
generate_migrations '-n', '-m'
|
1199
1207
|
|
1200
|
-
|
1201
|
-
|
1202
|
-
end
|
1208
|
+
migrations = Dir.glob('db/migrate/*declare_schema_migration*.rb')
|
1209
|
+
expect(migrations.size).to eq(1), migrations.inspect
|
1203
1210
|
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
end
|
1211
|
+
class Advert < active_record_base_class.constantize
|
1212
|
+
fields do
|
1213
|
+
price :integer, limit: 8
|
1208
1214
|
end
|
1209
|
-
|
1210
|
-
expect { generate_migrations '-n', '-g' }.to output("Database and models match -- nothing to change\n").to_stdout
|
1211
1215
|
end
|
1216
|
+
|
1217
|
+
expect { generate_migrations '-n', '-g' }.to output("Database and models match -- nothing to change\n").to_stdout
|
1212
1218
|
end
|
1213
1219
|
end
|
1214
1220
|
end
|
@@ -1250,16 +1256,6 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
1250
1256
|
ActiveRecord::Migration.class_eval(up)
|
1251
1257
|
expect(Advert.columns.map(&:name)).to eq(["id", "name"])
|
1252
1258
|
|
1253
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
1254
|
-
# Rails 4 drivers don't always create PK properly. Fix that by dropping and recreating.
|
1255
|
-
ActiveRecord::Base.connection.execute("drop table adverts")
|
1256
|
-
if defined?(Mysql2)
|
1257
|
-
ActiveRecord::Base.connection.execute("CREATE TABLE adverts (id integer PRIMARY KEY AUTO_INCREMENT NOT NULL, name varchar(250)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin")
|
1258
|
-
else
|
1259
|
-
ActiveRecord::Base.connection.execute("CREATE TABLE adverts (id integer PRIMARY KEY AUTOINCREMENT NOT NULL, name varchar(250))")
|
1260
|
-
end
|
1261
|
-
end
|
1262
|
-
|
1263
1259
|
class Advert < ActiveRecord::Base
|
1264
1260
|
declare_schema do
|
1265
1261
|
string :name, limit: 250, null: true
|
@@ -2046,7 +2042,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
2046
2042
|
nuke_model_class(Advertiser)
|
2047
2043
|
nuke_model_class(Affiliate)
|
2048
2044
|
end
|
2049
|
-
end if !defined?(SQLite3)
|
2045
|
+
end if !defined?(SQLite3)
|
2050
2046
|
|
2051
2047
|
describe 'serialize' do
|
2052
2048
|
before do
|
@@ -2233,13 +2229,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
2233
2229
|
end
|
2234
2230
|
|
2235
2231
|
context "for Rails #{ActiveSupport::VERSION::MAJOR}" do
|
2236
|
-
|
2237
|
-
|
2238
|
-
let(:optional_false) { { optional: false } }
|
2239
|
-
else
|
2240
|
-
let(:optional_true) { {} }
|
2241
|
-
let(:optional_false) { {} }
|
2242
|
-
end
|
2232
|
+
let(:optional_true) { { optional: true } }
|
2233
|
+
let(:optional_false) { { optional: false } }
|
2243
2234
|
let(:optional_flag) { { false => optional_false, true => optional_true } }
|
2244
2235
|
|
2245
2236
|
describe 'belongs_to' do
|
@@ -2348,9 +2339,9 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
2348
2339
|
end
|
2349
2340
|
class Fk < ActiveRecord::Base
|
2350
2341
|
declare_schema { }
|
2351
|
-
belongs_to :id_default, (
|
2352
|
-
belongs_to :id4, (
|
2353
|
-
belongs_to :id8, (
|
2342
|
+
belongs_to :id_default, ({})
|
2343
|
+
belongs_to :id4, ({})
|
2344
|
+
belongs_to :id8, ({})
|
2354
2345
|
end
|
2355
2346
|
end
|
2356
2347
|
|
@@ -2461,36 +2452,30 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
2461
2452
|
migration_content = File.read(migrations.first)
|
2462
2453
|
first_line = migration_content.split("\n").first
|
2463
2454
|
base_class = first_line.split(' < ').last
|
2464
|
-
expect(base_class).to eq("(
|
2455
|
+
expect(base_class).to eq("(ActiveRecord::Migration[4.2])")
|
2465
2456
|
end
|
2466
2457
|
end
|
2467
2458
|
|
2468
2459
|
context 'Does not generate migrations' do
|
2469
2460
|
it 'for aliased fields bigint -> integer limit 8' do
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
bigint :price
|
2474
|
-
end
|
2461
|
+
class Advert < active_record_base_class.constantize
|
2462
|
+
declare_schema do
|
2463
|
+
bigint :price
|
2475
2464
|
end
|
2465
|
+
end
|
2476
2466
|
|
2477
|
-
|
2478
|
-
|
2479
|
-
migrations = Dir.glob('db/migrate/*declare_schema_migration*.rb')
|
2480
|
-
expect(migrations.size).to eq(1), migrations.inspect
|
2467
|
+
generate_migrations '-n', '-m'
|
2481
2468
|
|
2482
|
-
|
2483
|
-
|
2484
|
-
end
|
2469
|
+
migrations = Dir.glob('db/migrate/*declare_schema_migration*.rb')
|
2470
|
+
expect(migrations.size).to eq(1), migrations.inspect
|
2485
2471
|
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
2489
|
-
end
|
2472
|
+
class Advert < active_record_base_class.constantize
|
2473
|
+
declare_schema do
|
2474
|
+
integer :price, limit: 8
|
2490
2475
|
end
|
2491
|
-
|
2492
|
-
expect { generate_migrations '-n', '-g' }.to output("Database and models match -- nothing to change\n").to_stdout
|
2493
2476
|
end
|
2477
|
+
|
2478
|
+
expect { generate_migrations '-n', '-g' }.to output("Database and models match -- nothing to change\n").to_stdout
|
2494
2479
|
end
|
2495
2480
|
end
|
2496
2481
|
|
@@ -14,11 +14,8 @@ RSpec.describe DeclareSchema::Model::Column do
|
|
14
14
|
|
15
15
|
describe 'class methods' do
|
16
16
|
describe '.native_type?' do
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
let(:native_types) { [:string, :text, :integer, :float, :decimal, :datetime, :time, :date, :binary, :boolean] }
|
21
|
-
end
|
17
|
+
let(:native_types) { [:string, :text, :integer, :float, :decimal, :datetime, :time, :date, :binary, :boolean, :json] }
|
18
|
+
|
22
19
|
|
23
20
|
it 'is falsey for :primary_key' do
|
24
21
|
expect(described_class.native_type?(:primary_key)).to be_falsey
|
@@ -63,19 +60,17 @@ RSpec.describe DeclareSchema::Model::Column do
|
|
63
60
|
end
|
64
61
|
|
65
62
|
describe '.deserialize_default_value' do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
63
|
+
it 'deserializes :boolean' do
|
64
|
+
expect(described_class.deserialize_default_value(nil, :boolean, 'true')).to eq(true)
|
65
|
+
expect(described_class.deserialize_default_value(nil, :boolean, 'false')).to eq(false)
|
66
|
+
end
|
71
67
|
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
it 'deserializes :integer' do
|
69
|
+
expect(described_class.deserialize_default_value(nil, :integer, '12')).to eq(12)
|
70
|
+
end
|
75
71
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
72
|
+
it 'deserializes :json' do
|
73
|
+
expect(described_class.deserialize_default_value(nil, :json, '{}')).to eq({})
|
79
74
|
end
|
80
75
|
end
|
81
76
|
end
|
@@ -110,16 +110,6 @@ RSpec.describe DeclareSchema::Model::IndexDefinition do
|
|
110
110
|
let(:model_class) { IndexDefinitionCompoundIndexModel }
|
111
111
|
|
112
112
|
it 'returns the indexes for the model' do
|
113
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
114
|
-
expect(model_class.connection).to receive(:primary_key).with('index_definition_compound_index_models').and_return(nil)
|
115
|
-
connection_stub = instance_double(ActiveRecord::Base.connection.class, "connection")
|
116
|
-
expect(connection_stub).to receive(:indexes).
|
117
|
-
with('index_definition_compound_index_models').
|
118
|
-
and_return([DeclareSchema::Model::IndexDefinition.new(model_class, ['fk1_id', 'fk2_id'], name: 'PRIMARY')])
|
119
|
-
|
120
|
-
expect(model_class.connection).to receive(:dup).and_return(connection_stub)
|
121
|
-
end
|
122
|
-
|
123
113
|
expect(subject.size).to eq(1), subject.inspect
|
124
114
|
expect([:name, :columns, :unique].map { |attr| subject[0].send(attr) }).to eq(
|
125
115
|
['PRIMARY', ['fk1_id', 'fk2_id'], true]
|
@@ -219,16 +209,6 @@ RSpec.describe DeclareSchema::Model::IndexDefinition do
|
|
219
209
|
let(:model_class) { IndexDefinitionCompoundIndexModel }
|
220
210
|
|
221
211
|
it 'returns the indexes for the model' do
|
222
|
-
if ActiveSupport::VERSION::MAJOR < 5
|
223
|
-
expect(model_class.connection).to receive(:primary_key).with('index_definition_compound_index_models').and_return(nil)
|
224
|
-
connection_stub = instance_double(ActiveRecord::Base.connection.class, "connection")
|
225
|
-
expect(connection_stub).to receive(:indexes).
|
226
|
-
with('index_definition_compound_index_models').
|
227
|
-
and_return([DeclareSchema::Model::IndexDefinition.new(model_class, ['fk1_id', 'fk2_id'], name: 'PRIMARY')])
|
228
|
-
|
229
|
-
expect(model_class.connection).to receive(:dup).and_return(connection_stub)
|
230
|
-
end
|
231
|
-
|
232
212
|
expect(subject.size).to eq(1), subject.inspect
|
233
213
|
expect([:name, :columns, :unique].map { |attr| subject[0].send(attr) }).to eq(
|
234
214
|
['PRIMARY', ['fk1_id', 'fk2_id'], true]
|
data/spec/spec_helper.rb
CHANGED
@@ -27,11 +27,7 @@ RSpec.configure do |config|
|
|
27
27
|
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 2_000
|
28
28
|
|
29
29
|
def active_record_base_class
|
30
|
-
|
31
|
-
'ActiveRecord::Base'
|
32
|
-
else
|
33
|
-
'ApplicationRecord'
|
34
|
-
end
|
30
|
+
'ApplicationRecord'
|
35
31
|
end
|
36
32
|
|
37
33
|
def migrate(renames = {})
|
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: 0.
|
4
|
+
version: 0.14.1
|
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: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
description: Declare your Rails/active_record model schemas and have database migrations
|
28
28
|
generated for you!
|
29
29
|
email: development@invoca.com
|
@@ -49,8 +49,6 @@ files:
|
|
49
49
|
- bin/declare_schema
|
50
50
|
- declare_schema.gemspec
|
51
51
|
- gemfiles/.bundle/config
|
52
|
-
- gemfiles/rails_4_mysql.gemfile
|
53
|
-
- gemfiles/rails_4_sqlite.gemfile
|
54
52
|
- gemfiles/rails_5_mysql.gemfile
|
55
53
|
- gemfiles/rails_5_sqlite.gemfile
|
56
54
|
- gemfiles/rails_6_mysql.gemfile
|
@@ -143,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
141
|
- !ruby/object:Gem::Version
|
144
142
|
version: 1.3.6
|
145
143
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.1.2
|
147
145
|
signing_key:
|
148
146
|
specification_version: 4
|
149
147
|
summary: Database schema declaration and migration generator for Rails
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "bundler", "< 2"
|
7
|
-
gem "climate_control", "~> 0.2"
|
8
|
-
gem "pry"
|
9
|
-
gem "pry-byebug"
|
10
|
-
gem "rails", "~> 4.2"
|
11
|
-
gem "responders"
|
12
|
-
gem "rspec"
|
13
|
-
gem "rubocop"
|
14
|
-
gem "yard"
|
15
|
-
gem "mysql2"
|
16
|
-
|
17
|
-
group :testapp do
|
18
|
-
gem "bootsnap", ">= 1.1.0", require: false
|
19
|
-
gem "listen"
|
20
|
-
end
|
21
|
-
|
22
|
-
gemspec path: "../"
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "bundler", "< 2"
|
7
|
-
gem "climate_control", "~> 0.2"
|
8
|
-
gem "pry"
|
9
|
-
gem "pry-byebug"
|
10
|
-
gem "rails", "~> 4.2"
|
11
|
-
gem "responders"
|
12
|
-
gem "rspec"
|
13
|
-
gem "rubocop"
|
14
|
-
gem "yard"
|
15
|
-
gem "sqlite3", "~> 1.3.0"
|
16
|
-
|
17
|
-
group :testapp do
|
18
|
-
gem "bootsnap", ">= 1.1.0", require: false
|
19
|
-
gem "listen"
|
20
|
-
end
|
21
|
-
|
22
|
-
gemspec path: "../"
|