declare_schema 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ba6099c2cfd605309415e3a14d53ba36aecad45285c4babdc385fa3576225ff
4
- data.tar.gz: 60c009064977df314115e0bd1db8e811ba05866e24ac652a31b3ec4bc25291f5
3
+ metadata.gz: 2d831ee175d229d9c618cffa6b89fa375eb15bf2e9121feb732d474e46048051
4
+ data.tar.gz: 1ea6d18318ad4f02591e68491b526b062e4d3b0e628b5ac7512987ed0f5772d1
5
5
  SHA512:
6
- metadata.gz: 9a7308b18a3a38c4713a2effb7f7f9dcf6b75702703152292061d4e266ada35b7be47e4ab43322965f9bfb0c88886ee138bea984bf0e09a9d37dde8bd1fe2da5
7
- data.tar.gz: 10c67731046059b1ae1ff483ae979f4b649805deac4559ae2e4533082fa4e4a66e237814ff5873c638543ed533a5f660bf1dd204a5e3a8356fe377da1769d388
6
+ metadata.gz: 2bb053f279aab8ab554d7258abdd9781c2b8981e4086a03a527c6541dcb2dbff27fd2770370d907ff463f54417d11228b8040e0e738ee822f9588ff292c46b25
7
+ data.tar.gz: 5504007956e98a03c051c7b28272fe92a09165d59e29dc395900cbeb726c90bb06f243d313f08f27e74d4efe0c65a53ca92a9761f4fe020a00ad2e3794de27a2
@@ -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] - 2023-01-27
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (1.2.1)
4
+ declare_schema (1.2.2)
5
5
  rails (>= 5.0)
6
6
 
7
7
  GEM
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
 
@@ -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 name, validates_options
230
+ validates(name, **validates_options)
231
231
  end
232
232
 
233
233
  # Support for custom validations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeclareSchema
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
5
5
  end
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.1
4
+ version: 1.2.2
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: 2022-09-25 00:00:00.000000000 Z
11
+ date: 2023-01-27 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: []