declare_schema 2.3.0 → 2.3.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/workflows/{declare_schema_build.yml → pipeline.yml} +7 -21
- data/Appraisals +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +8 -1
- data/catalog-info.yaml +2 -0
- data/gemfiles/rails_7_0.gemfile +4 -0
- data/gemfiles/rails_7_1.gemfile +4 -0
- data/gemfiles/rails_7_2.gemfile +4 -0
- data/gemfiles/{rails_6_1.gemfile → rails_8_0.gemfile} +5 -1
- data/lib/declare_schema/dsl.rb +0 -2
- data/lib/declare_schema/field_declaration_dsl.rb +0 -2
- data/lib/declare_schema/model.rb +1 -1
- data/lib/declare_schema/version.rb +1 -1
- data/lib/generators/declare_schema/migration/migration_generator.rb +1 -1
- data/spec/lib/declare_schema/migration_generator_spec.rb +16 -6
- data/spec/lib/declare_schema/model/table_options_definition_spec.rb +10 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b38ba5f14cb9ff014da1baaf10698db6e1ad744aa50804e62c2a958d75f26c47
|
|
4
|
+
data.tar.gz: 526ab470daae916fcb233fa397d385feef77b7933237219e733db1543bef7184
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18768edfdc06e9562246243d1d91e698545f0dfceefbcd48a29894733a684493e2c521cc782bbd45767d0980479c17657a12bc7ec25242d594ac4851b62925c5
|
|
7
|
+
data.tar.gz: 760e5374a42726af4a3eb04f3c6063c1266d3384a5c23082d671b0485ce341b58c0ac5cf6726a49b5ddeb73d01cccd8213e81ea64eee1ac19fa219b3bdefb961
|
|
@@ -4,39 +4,25 @@ on: [push]
|
|
|
4
4
|
name: DeclareSchema Build
|
|
5
5
|
|
|
6
6
|
jobs:
|
|
7
|
-
|
|
7
|
+
tests:
|
|
8
8
|
name: DeclareSchema Build
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
13
|
adapter: [mysql, postgresql, sqlite3]
|
|
14
|
-
ruby: [
|
|
14
|
+
ruby: [3.1, 3.2, 3.3, 3.4]
|
|
15
15
|
gemfile:
|
|
16
|
-
- gemfiles/rails_6_1.gemfile
|
|
17
16
|
- gemfiles/rails_7_0.gemfile
|
|
18
17
|
- gemfiles/rails_7_1.gemfile
|
|
19
18
|
- gemfiles/rails_7_2.gemfile
|
|
19
|
+
- gemfiles/rails_8_0.gemfile
|
|
20
20
|
exclude:
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- adapter: postgresql
|
|
25
|
-
ruby: 3.3
|
|
26
|
-
gemfile: gemfiles/rails_6_1.gemfile
|
|
21
|
+
- ruby: 3.1
|
|
22
|
+
gemfile: gemfiles/rails_8_0.gemfile
|
|
23
|
+
# TODO: Support SQLite3 with Rails 8.0
|
|
27
24
|
- adapter: sqlite3
|
|
28
|
-
|
|
29
|
-
gemfile: gemfiles/rails_6_1.gemfile
|
|
30
|
-
- adapter: mysql
|
|
31
|
-
ruby: '3.0'
|
|
32
|
-
gemfile: gemfiles/rails_7_2.gemfile
|
|
33
|
-
- adapter: postgresql
|
|
34
|
-
ruby: '3.0'
|
|
35
|
-
gemfile: gemfiles/rails_7_2.gemfile
|
|
36
|
-
- adapter: sqlite3
|
|
37
|
-
ruby: '3.0'
|
|
38
|
-
gemfile: gemfiles/rails_7_2.gemfile
|
|
39
|
-
|
|
25
|
+
gemfile: gemfiles/rails_8_0.gemfile
|
|
40
26
|
env:
|
|
41
27
|
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
|
42
28
|
MYSQL_HOST: 127.0.0.1
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ 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
|
+
## [2.3.2] - 2025-02-21
|
|
8
|
+
### Fixed
|
|
9
|
+
- Removed require of `activesupport/proxy_object` which is removed in Rails 8.0
|
|
10
|
+
|
|
11
|
+
## [2.3.1] - 2024-12-10
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fixed bug where a new model with `belongs_to :owner, polymorphic: true` would cause
|
|
14
|
+
a "Mysql2::Error: Table '<new table>' doesn't exist:" exception when generating a migration.
|
|
15
|
+
|
|
7
16
|
## [2.3.0] - 2024-10-31
|
|
8
17
|
### Updated
|
|
9
18
|
- Updated the `current_adapter` method to use `connection_db_config` for Rails 6.1 and higher, while retaining `connection_config` for earlier versions
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
declare_schema (2.3.
|
|
4
|
+
declare_schema (2.3.2)
|
|
5
5
|
rails (>= 6.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -71,6 +71,8 @@ GEM
|
|
|
71
71
|
rake
|
|
72
72
|
thor (>= 0.14.0)
|
|
73
73
|
ast (2.4.2)
|
|
74
|
+
base64 (0.2.0)
|
|
75
|
+
bigdecimal (3.1.9)
|
|
74
76
|
bootsnap (1.18.4)
|
|
75
77
|
msgpack (~> 1.2)
|
|
76
78
|
builder (3.3.0)
|
|
@@ -106,6 +108,7 @@ GEM
|
|
|
106
108
|
mini_portile2 (2.8.7)
|
|
107
109
|
minitest (5.25.0)
|
|
108
110
|
msgpack (1.7.2)
|
|
111
|
+
mutex_m (0.3.0)
|
|
109
112
|
mysql2 (0.5.6)
|
|
110
113
|
net-imap (0.4.14)
|
|
111
114
|
date
|
|
@@ -228,11 +231,15 @@ PLATFORMS
|
|
|
228
231
|
|
|
229
232
|
DEPENDENCIES
|
|
230
233
|
appraisal
|
|
234
|
+
base64 (>= 0.2.0)
|
|
235
|
+
bigdecimal (>= 3.1)
|
|
231
236
|
bootsnap (>= 1.1.0)
|
|
232
237
|
climate_control (~> 0.2)
|
|
238
|
+
concurrent-ruby (~> 1.3, < 1.3.5)
|
|
233
239
|
declare_schema!
|
|
234
240
|
listen
|
|
235
241
|
mail
|
|
242
|
+
mutex_m (>= 0.3.0)
|
|
236
243
|
mysql2 (~> 0.5)
|
|
237
244
|
net-smtp
|
|
238
245
|
pg (~> 1.1)
|
data/catalog-info.yaml
CHANGED
data/gemfiles/rails_7_0.gemfile
CHANGED
|
@@ -17,6 +17,10 @@ gem "yard"
|
|
|
17
17
|
gem "mysql2", "~> 0.5"
|
|
18
18
|
gem "pg", "~> 1.1"
|
|
19
19
|
gem "sqlite3", "~> 1.4"
|
|
20
|
+
gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
|
|
21
|
+
gem "base64", ">= 0.2.0"
|
|
22
|
+
gem "bigdecimal", ">= 3.1"
|
|
23
|
+
gem "mutex_m", ">= 0.3.0"
|
|
20
24
|
|
|
21
25
|
group :testapp do
|
|
22
26
|
gem "bootsnap", ">= 1.1.0", require: false
|
data/gemfiles/rails_7_1.gemfile
CHANGED
|
@@ -17,6 +17,10 @@ gem "yard"
|
|
|
17
17
|
gem "mysql2", "~> 0.5"
|
|
18
18
|
gem "pg", "~> 1.1"
|
|
19
19
|
gem "sqlite3", "~> 1.4"
|
|
20
|
+
gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
|
|
21
|
+
gem "base64", ">= 0.2.0"
|
|
22
|
+
gem "bigdecimal", ">= 3.1"
|
|
23
|
+
gem "mutex_m", ">= 0.3.0"
|
|
20
24
|
|
|
21
25
|
group :testapp do
|
|
22
26
|
gem "bootsnap", ">= 1.1.0", require: false
|
data/gemfiles/rails_7_2.gemfile
CHANGED
|
@@ -17,6 +17,10 @@ gem "yard"
|
|
|
17
17
|
gem "mysql2", "~> 0.5"
|
|
18
18
|
gem "pg", "~> 1.1"
|
|
19
19
|
gem "sqlite3", "~> 1.4"
|
|
20
|
+
gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
|
|
21
|
+
gem "base64", ">= 0.2.0"
|
|
22
|
+
gem "bigdecimal", ">= 3.1"
|
|
23
|
+
gem "mutex_m", ">= 0.3.0"
|
|
20
24
|
|
|
21
25
|
group :testapp do
|
|
22
26
|
gem "bootsnap", ">= 1.1.0", require: false
|
|
@@ -8,7 +8,7 @@ gem "mail"
|
|
|
8
8
|
gem "net-smtp"
|
|
9
9
|
gem "pry"
|
|
10
10
|
gem "pry-byebug"
|
|
11
|
-
gem "rails", "~>
|
|
11
|
+
gem "rails", "~> 8.0.0"
|
|
12
12
|
gem "responders"
|
|
13
13
|
gem "rspec"
|
|
14
14
|
gem "rspec-its"
|
|
@@ -17,6 +17,10 @@ gem "yard"
|
|
|
17
17
|
gem "mysql2", "~> 0.5"
|
|
18
18
|
gem "pg", "~> 1.1"
|
|
19
19
|
gem "sqlite3", "~> 1.4"
|
|
20
|
+
gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
|
|
21
|
+
gem "base64", ">= 0.2.0"
|
|
22
|
+
gem "bigdecimal", ">= 3.1"
|
|
23
|
+
gem "mutex_m", ">= 0.3.0"
|
|
20
24
|
|
|
21
25
|
group :testapp do
|
|
22
26
|
gem "bootsnap", ">= 1.1.0", require: false
|
data/lib/declare_schema/dsl.rb
CHANGED
data/lib/declare_schema/model.rb
CHANGED
|
@@ -240,7 +240,7 @@ module DeclareSchema
|
|
|
240
240
|
|
|
241
241
|
def _infer_fk_limit(foreign_key_column, reflection)
|
|
242
242
|
if reflection.options[:polymorphic]
|
|
243
|
-
if (foreign_key_column =
|
|
243
|
+
if (foreign_key_column = _column(foreign_key_column)) && foreign_key_column.type == :integer
|
|
244
244
|
foreign_key_column.limit
|
|
245
245
|
end
|
|
246
246
|
else
|
|
@@ -68,7 +68,7 @@ module DeclareSchema
|
|
|
68
68
|
final_migration_name =
|
|
69
69
|
name.presence ||
|
|
70
70
|
if !options[:default_name]
|
|
71
|
-
choose("
|
|
71
|
+
choose("Migration filename (spaces will be converted to _) [#{default_migration_name}]:", /^[a-z0-9_ ]*$/,
|
|
72
72
|
default_migration_name).strip.gsub(' ', '_').presence
|
|
73
73
|
end ||
|
|
74
74
|
default_migration_name
|
|
@@ -899,7 +899,12 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
899
899
|
end
|
|
900
900
|
up, _down = Generators::DeclareSchema::Migration::Migrator.run
|
|
901
901
|
ActiveRecord::Migration.class_eval(up)
|
|
902
|
-
|
|
902
|
+
|
|
903
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4")
|
|
904
|
+
expect(Ad.field_specs['company'].options[:validates].inspect).to eq("{:presence=>true, :uniqueness=>{:case_sensitive=>false}}")
|
|
905
|
+
else
|
|
906
|
+
expect(Ad.field_specs['company'].options[:validates].inspect).to eq("{presence: true, uniqueness: {case_sensitive: false}}")
|
|
907
|
+
end
|
|
903
908
|
|
|
904
909
|
# DeclareSchema supports has_and_belongs_to_many relationships and generates the intersection ("join") table
|
|
905
910
|
# with appropriate primary key, indexes, and foreign keys.
|
|
@@ -1305,6 +1310,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1305
1310
|
belongs_to :id_default
|
|
1306
1311
|
belongs_to :id4
|
|
1307
1312
|
belongs_to :id8
|
|
1313
|
+
belongs_to :owner, polymorphic: true
|
|
1308
1314
|
end
|
|
1309
1315
|
end
|
|
1310
1316
|
|
|
@@ -1332,20 +1338,24 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
1332
1338
|
it 'infers the correct FK type from the create_table id: type' do
|
|
1333
1339
|
up = Generators::DeclareSchema::Migration::Migrator.run.first
|
|
1334
1340
|
|
|
1335
|
-
create_fks = up.split("\n").grep(/t\.integer /).map { |command| command.gsub(', null: false', '').gsub(/^ +/, '') }
|
|
1341
|
+
create_fks = up.split("\n").grep(/t\.integer|string /).map { |command| command.gsub(', null: false', '').gsub(/^ +/, '') }
|
|
1336
1342
|
if current_adapter == 'sqlite3'
|
|
1337
1343
|
create_fks.map! { |command| command.gsub(/limit: [a-z0-9]+/, 'limit: X') }
|
|
1338
1344
|
expect(create_fks).to eq([
|
|
1339
1345
|
't.integer :id_default_id, limit: X',
|
|
1340
1346
|
't.integer :id4_id, limit: X',
|
|
1341
|
-
't.integer :id8_id, limit: X'
|
|
1342
|
-
|
|
1347
|
+
't.integer :id8_id, limit: X',
|
|
1348
|
+
't.integer :owner_id, limit: X',
|
|
1349
|
+
't.string :owner_type, limit: X'
|
|
1350
|
+
])
|
|
1343
1351
|
else
|
|
1344
1352
|
expect(create_fks).to eq([
|
|
1345
1353
|
't.integer :id_default_id, limit: 8',
|
|
1346
1354
|
't.integer :id4_id, limit: 4',
|
|
1347
|
-
't.integer :id8_id, limit: 8'
|
|
1348
|
-
|
|
1355
|
+
't.integer :id8_id, limit: 8',
|
|
1356
|
+
't.integer :owner_id, limit: 8',
|
|
1357
|
+
"t.string :owner_type, limit: 255#{charset_and_collation}"
|
|
1358
|
+
])
|
|
1349
1359
|
end
|
|
1350
1360
|
end
|
|
1351
1361
|
|
|
@@ -24,7 +24,11 @@ RSpec.describe DeclareSchema::Model::TableOptionsDefinition do
|
|
|
24
24
|
|
|
25
25
|
describe '#to_key' do
|
|
26
26
|
subject { model.to_key }
|
|
27
|
-
|
|
27
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4")
|
|
28
|
+
it { is_expected.to eq(['table_options_definition_test_models', "{:charset=>#{charset.inspect}, :collation=>#{collation.inspect}}"]) }
|
|
29
|
+
else
|
|
30
|
+
it { is_expected.to eq(['table_options_definition_test_models', "{charset: #{charset.inspect}, collation: #{collation.inspect}}"]) }
|
|
31
|
+
end
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
describe '#settings' do
|
|
@@ -56,7 +60,11 @@ RSpec.describe DeclareSchema::Model::TableOptionsDefinition do
|
|
|
56
60
|
|
|
57
61
|
describe '#hash' do
|
|
58
62
|
subject { model.hash }
|
|
59
|
-
|
|
63
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4")
|
|
64
|
+
it { is_expected.to eq(['table_options_definition_test_models', "{:charset=>#{charset.inspect}, :collation=>#{collation.inspect}}"].hash) }
|
|
65
|
+
else
|
|
66
|
+
it { is_expected.to eq(['table_options_definition_test_models', "{charset: #{charset.inspect}, collation: #{collation.inspect}}"].hash) }
|
|
67
|
+
end
|
|
60
68
|
end
|
|
61
69
|
|
|
62
70
|
describe '#to_s' do
|
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: 2.3.
|
|
4
|
+
version: 2.3.2
|
|
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:
|
|
11
|
+
date: 2025-02-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -37,8 +37,8 @@ files:
|
|
|
37
37
|
- ".devcontainer/devcontainer.json"
|
|
38
38
|
- ".devcontainer/docker-compose.yml"
|
|
39
39
|
- ".github/CODEOWNERS"
|
|
40
|
-
- ".github/workflows/declare_schema_build.yml"
|
|
41
40
|
- ".github/workflows/gem_release.yml"
|
|
41
|
+
- ".github/workflows/pipeline.yml"
|
|
42
42
|
- ".gitignore"
|
|
43
43
|
- ".rspec"
|
|
44
44
|
- ".rubocop.yml"
|
|
@@ -57,10 +57,10 @@ files:
|
|
|
57
57
|
- config/brakeman.ignore
|
|
58
58
|
- declare_schema.gemspec
|
|
59
59
|
- gemfiles/.bundle/config
|
|
60
|
-
- gemfiles/rails_6_1.gemfile
|
|
61
60
|
- gemfiles/rails_7_0.gemfile
|
|
62
61
|
- gemfiles/rails_7_1.gemfile
|
|
63
62
|
- gemfiles/rails_7_2.gemfile
|
|
63
|
+
- gemfiles/rails_8_0.gemfile
|
|
64
64
|
- lib/declare_schema.rb
|
|
65
65
|
- lib/declare_schema/command.rb
|
|
66
66
|
- lib/declare_schema/dsl.rb
|
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
159
|
version: 1.3.6
|
|
160
160
|
requirements: []
|
|
161
|
-
rubygems_version: 3.
|
|
161
|
+
rubygems_version: 3.5.10
|
|
162
162
|
signing_key:
|
|
163
163
|
specification_version: 4
|
|
164
164
|
summary: Database schema declaration and migration generator for Rails
|