declare_schema 1.2.1 → 1.2.2.pre.0
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 -5
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +34 -0
- data/lib/declare_schema/model.rb +1 -1
- data/lib/declare_schema/version.rb +1 -1
- 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: 845f78b84a0a36a5d218c35351b1445d669b512b96745ee7bf7ab6a2a0a97277
|
4
|
+
data.tar.gz: d983c4fb5d5e3bb123854a8dada61c02970de010331770f77ab3630c084c8a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bcf9de4ccb29f0679ebe15f3892858e628bda5ed4eb30b7d7860d687a2233df7b24d7a913772b8b4d312ab378bcdc4b2fa1675b17f9d69e20d166d1eb0f0dba
|
7
|
+
data.tar.gz: 8e21e6bc2a9d5dd6f3ab40b971cf6f31de66901049f28b17f927d40ae247ecd6c7af60bfe300f9f27b15af0e58df205a3de7e9f97a5dc4a94c8c5bf7b5602a8c
|
@@ -16,11 +16,6 @@ jobs:
|
|
16
16
|
- gemfiles/rails_5_sqlite.gemfile
|
17
17
|
- gemfiles/rails_6_mysql.gemfile
|
18
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
|
24
19
|
exclude:
|
25
20
|
- ruby: '3.0'
|
26
21
|
gemfile: gemfiles/rails_5_mysql.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,17 @@ 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.2.2] - Unreleased
|
8
|
+
### Changed
|
9
|
+
- Documented `belongs_to` and `has_and_belongs_to_many` behavior
|
10
|
+
- Documented configurable ignored tables behavior
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Ruby 3.x kwargs issue when calling `validates`
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
- Ruby 2.5 from test matrix
|
17
|
+
|
7
18
|
## [1.2.1] - 2022-09-25
|
8
19
|
### Fixed
|
9
20
|
- If Rails is defined, raise if `Rails.application` is `nil`.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -224,6 +224,40 @@ If your repo has a different command to run for migrations, you can configure it
|
|
224
224
|
`DeclareSchema.db_migrate_command = "bundle exec rails db:migrate_immediate"`
|
225
225
|
```
|
226
226
|
|
227
|
+
## The `belongs_to` Association
|
228
|
+
The foreign key for a `belongs_to` association refers to the primary key of the associated model. The `belongs_to`
|
229
|
+
association is outside of the `declare_schema do` block, so `declare_schema` intercepts the `belongs_to` macro to
|
230
|
+
infer the foreign key column.
|
231
|
+
|
232
|
+
By default, `declare_schema` creates an index for `belongs_to` relations. If this default index is not desired,
|
233
|
+
you can use `index: false` in the `belongs_to` expression. This may be the case if for example a different index
|
234
|
+
already accounts for it.
|
235
|
+
|
236
|
+
## The `has_and_belongs_to_many` Association
|
237
|
+
Like the `belongs_to` association, `has_and_belongs_to_many` is outside of the `declare_schema ` block. `declare_schema` similarly
|
238
|
+
infers foreign keys (and the intersection table).
|
239
|
+
|
240
|
+
## Ignored Tables
|
241
|
+
If a table's schema or metadata are managed elsewhere, `declare_schema` probably should not alter it. Accordingly,
|
242
|
+
`declare_schema` can be configured to ignore tables.
|
243
|
+
|
244
|
+
`declare_schema` by default ignores these tables:
|
245
|
+
- The ActiveRecord `schema_info` table
|
246
|
+
- The ActiveRecord schema migrations table (generally named `schema_migrations`)
|
247
|
+
- The ActiveRecord internal metadata table (generally named `ar_internal_metadata`)
|
248
|
+
- If defined/configured, the CGI ActiveRecordStore session table
|
249
|
+
|
250
|
+
Additional tables can be ignored by configuring `Generators::DeclareSchema::Migration::Migrator.ignore_tables`.
|
251
|
+
For example:
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
::Generators::DeclareSchema::Migration::Migrator.ignore_tables = [
|
255
|
+
"delayed_jobs",
|
256
|
+
"my_snowflake_table",
|
257
|
+
...
|
258
|
+
]
|
259
|
+
```
|
260
|
+
|
227
261
|
## Declaring Character Set and Collation
|
228
262
|
_Note: This feature currently only works for MySQL database configurations._
|
229
263
|
|
data/lib/declare_schema/model.rb
CHANGED
@@ -227,7 +227,7 @@ module DeclareSchema
|
|
227
227
|
validates_uniqueness_of name, allow_nil: !:required.in?(args) if :unique.in?(args)
|
228
228
|
|
229
229
|
if (validates_options = options[:validates])
|
230
|
-
validates
|
230
|
+
validates(name, **validates_options)
|
231
231
|
end
|
232
232
|
|
233
233
|
# Support for custom validations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: declare_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2.pre.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -127,7 +127,7 @@ homepage: https://github.com/Invoca/declare_schema
|
|
127
127
|
licenses: []
|
128
128
|
metadata:
|
129
129
|
allowed_push_host: https://rubygems.org
|
130
|
-
post_install_message:
|
130
|
+
post_install_message:
|
131
131
|
rdoc_options: []
|
132
132
|
require_paths:
|
133
133
|
- lib
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: 1.3.6
|
144
144
|
requirements: []
|
145
145
|
rubygems_version: 3.1.6
|
146
|
-
signing_key:
|
146
|
+
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Database schema declaration and migration generator for Rails
|
149
149
|
test_files: []
|