declare_schema 1.2.0 → 1.2.2.pre.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc7ce9fd6b89826b6a170f3a7cac65598170b96225b5e8957407558d5fbca61f
4
- data.tar.gz: 5141c495a2b66ebd4e1d088f68f33f3ba85455827bb35437c96a2117e5c20127
3
+ metadata.gz: 845f78b84a0a36a5d218c35351b1445d669b512b96745ee7bf7ab6a2a0a97277
4
+ data.tar.gz: d983c4fb5d5e3bb123854a8dada61c02970de010331770f77ab3630c084c8a04
5
5
  SHA512:
6
- metadata.gz: 1edff05f2f7b5efbf7eeb8ce56e27b87744866b0c788795eaab0bd228fa700869a4dd13c4e38f47df18ee0ac67bd5eb091ae4df799b94adb1970edf572801c9a
7
- data.tar.gz: 5d0e4633314231757af2bd1ae519eaff9714a91d6af4ca535ada1e9467067046e14c3db0bd7363cd1b20c8647526d64e2ab3ebf6503206f17e440503b7ebed34
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,21 @@ 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
+
18
+ ## [1.2.1] - 2022-09-25
19
+ ### Fixed
20
+ - If Rails is defined, raise if `Rails.application` is `nil`.
21
+
7
22
  ## [1.2.0] - 2022-09-14
8
23
  ### Added
9
24
  - Added a rake task definition that can be optionally included into a non-Rails project to generate
@@ -238,6 +253,7 @@ using the appropriate Rails configuration attributes.
238
253
  ### Added
239
254
  - Initial version from https://github.com/Invoca/hobo_fields v4.1.0.
240
255
 
256
+ [1.2.1]: https://github.com/Invoca/declare_schema/compare/v1.2.0...v1.2.1
241
257
  [1.2.0]: https://github.com/Invoca/declare_schema/compare/v1.1.0...v1.2.0
242
258
  [1.1.0]: https://github.com/Invoca/declare_schema/compare/v1.0.2...v1.1.0
243
259
  [1.0.2]: https://github.com/Invoca/declare_schema/compare/v1.0.1...v1.0.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (1.2.0)
4
+ declare_schema (1.2.2.pre.0)
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.0"
4
+ VERSION = "1.2.2.pre.0"
5
5
  end
@@ -55,6 +55,7 @@ module Generators
55
55
  def load_rails_models
56
56
  ActiveRecord::Migration.verbose = false
57
57
  if defined?(Rails)
58
+ Rails.application or raise "Rails is defined, so Rails.application must be set"
58
59
  Rails.application.eager_load!
59
60
  Rails::Engine.subclasses.each(&:eager_load!)
60
61
  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.0
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
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails