declare_schema 4.0.3 → 4.1.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +22 -2
- data/docs/superpowers/plans/2026-07-03-ignore-tables-ignore-models-deprecation.md +431 -0
- data/docs/superpowers/specs/2026-07-03-ignore-tables-deprecation-design.md +99 -0
- data/lib/declare_schema/version.rb +1 -1
- data/lib/declare_schema.rb +13 -1
- data/lib/generators/declare_schema/migration/migrator.rb +7 -7
- data/spec/lib/declare_schema/migration_generator_spec.rb +3 -1
- data/spec/lib/declare_schema_spec.rb +52 -0
- data/spec/lib/generators/declare_schema/migration/migrator_spec.rb +42 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 515b75b80f3aec9fa977aebe9874ad015bd16def4a07ed0f7c86fee3fd51e6ac
|
|
4
|
+
data.tar.gz: 5bac16aa76fcb28b74b0beaae97c7ddd6f4e7a5f939feae9f4948f7ef1f74606
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5db28ddddef093068697c0caf0f1797eacf82bb94e6b56353dc5b31bae8c442ccab1287eea8495e9ade030f41d1053031d6499c688e4588667b6e8748bcff2c9
|
|
7
|
+
data.tar.gz: c433348df1b1ae6db97878e2afac920f8fafff5d19995fe75a297be6d01d05ec4db1f183249457a2b5a86c7d2fd4cfa6f36b3f0db2042571960e7a19fe7056f9
|
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
|
+
## [4.1.0] - 2026-07-07
|
|
8
|
+
### Added
|
|
9
|
+
- `::DeclareSchema.ignore_tables` and `::DeclareSchema.ignore_models` as the new public
|
|
10
|
+
settings for ignoring tables/models during migration generation.
|
|
11
|
+
|
|
12
|
+
### Deprecated
|
|
13
|
+
- `Generators::DeclareSchema::Migration::Migrator.ignore_tables` and `.ignore_models` in
|
|
14
|
+
favor of `DeclareSchema.ignore_tables` and `DeclareSchema.ignore_models` above. The
|
|
15
|
+
`Migrator` accessors still work but emit a deprecation warning; they will not be
|
|
16
|
+
removed without a major version bump.
|
|
17
|
+
|
|
7
18
|
## [4.0.3] - 2026-07-01
|
|
8
19
|
### Changed
|
|
9
20
|
- Documented the `field` DSL macro and the underlying `declare_field` class method.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -376,23 +376,43 @@ infers foreign keys (and the intersection table).
|
|
|
376
376
|
|
|
377
377
|
## Ignored Tables
|
|
378
378
|
If a table's schema or metadata are managed elsewhere, `declare_schema` can be instructed to ignore it
|
|
379
|
-
by adding those table names to the array assigned to `
|
|
379
|
+
by adding those table names to the array assigned to `DeclareSchema.ignore_tables`.
|
|
380
380
|
For example:
|
|
381
381
|
|
|
382
382
|
```ruby
|
|
383
|
-
::
|
|
383
|
+
::DeclareSchema.ignore_tables = [
|
|
384
384
|
"delayed_jobs",
|
|
385
385
|
"my_snowflake_table",
|
|
386
386
|
...
|
|
387
387
|
]
|
|
388
388
|
```
|
|
389
389
|
|
|
390
|
+
**Deprecated:** `Generators::DeclareSchema::Migration::Migrator.ignore_tables` is a deprecated alias for
|
|
391
|
+
`DeclareSchema.ignore_tables` above. New code should use `DeclareSchema.ignore_tables` directly;
|
|
392
|
+
`Migrator.ignore_tables` will be removed in version 5.0.
|
|
393
|
+
|
|
390
394
|
Note: `declare_schema` always ignores these tables:
|
|
391
395
|
- The ActiveRecord `schema_info` table
|
|
392
396
|
- The ActiveRecord schema migrations table (generally named `schema_migrations`)
|
|
393
397
|
- The ActiveRecord internal metadata table (generally named `ar_internal_metadata`)
|
|
394
398
|
- If defined/configured, the CGI ActiveRecordStore session table
|
|
395
399
|
|
|
400
|
+
## Ignored Models
|
|
401
|
+
Similarly, `declare_schema` can be instructed to ignore specific models (so that no migration is
|
|
402
|
+
generated for their table) by adding the model's underscored name to the array assigned to
|
|
403
|
+
`DeclareSchema.ignore_models`. For example:
|
|
404
|
+
|
|
405
|
+
```ruby
|
|
406
|
+
::DeclareSchema.ignore_models = [
|
|
407
|
+
"my_legacy_model",
|
|
408
|
+
...
|
|
409
|
+
]
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**Deprecated:** `Generators::DeclareSchema::Migration::Migrator.ignore_models` is a deprecated alias for
|
|
413
|
+
`DeclareSchema.ignore_models` above. New code should use `DeclareSchema.ignore_models` directly;
|
|
414
|
+
`Migrator.ignore_models` will be removed in version 5.0.
|
|
415
|
+
|
|
396
416
|
## Maximum Length of Index and Constraint Names
|
|
397
417
|
|
|
398
418
|
MySQL limits the length of index and constraint names to 64 characters.
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# DeclareSchema.ignore_tables/ignore_models Deprecation Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Move the `ignore_tables` and `ignore_models` settings from the internal `Generators::DeclareSchema::Migration::Migrator` class to the public `::DeclareSchema` module, keeping the old `Migrator` accessors working but deprecated.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Reuse the exact pattern already used in this codebase for `default_charset`/`default_collation` (see `lib/generators/declare_schema/migration/migrator.rb`): the setting becomes a plain `attr_accessor` on `::DeclareSchema`, and `Migrator` gets `delegate ... to: ::DeclareSchema` + `deprecate ...` for the old names, sharing the existing `ActiveSupport::Deprecation.new('1.0', 'declare_schema')` instance.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Ruby, Rails/ActiveSupport (`Module#delegate`, `Module#deprecate`, `ActiveSupport::Deprecation`), RSpec.
|
|
10
|
+
|
|
11
|
+
## Global Constraints
|
|
12
|
+
|
|
13
|
+
- No removal of `Migrator.ignore_tables`/`ignore_models` — deprecate only, so no major version bump is required.
|
|
14
|
+
- Version bump: `4.0.3` → `4.1.0` (minor).
|
|
15
|
+
- Spec reference: [OCTO-893](https://invoca.atlassian.net/browse/OCTO-893).
|
|
16
|
+
- Design doc: `docs/superpowers/specs/2026-07-03-ignore-tables-deprecation-design.md`.
|
|
17
|
+
- Work happens on branch `OCTO-893/deprecate-migrator-ignore-tables` (already created, already has 1 commit with the design doc).
|
|
18
|
+
- No gem release/publish and no push to `origin` as part of this plan — local commits only.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Task 1: Move `ignore_tables`/`ignore_models` to `::DeclareSchema`, deprecate on `Migrator`
|
|
23
|
+
|
|
24
|
+
**Files:**
|
|
25
|
+
- Modify: `lib/declare_schema.rb`
|
|
26
|
+
- Modify: `lib/generators/declare_schema/migration/migrator.rb`
|
|
27
|
+
- Test: `spec/lib/generators/declare_schema/migration/migrator_spec.rb`
|
|
28
|
+
- Modify: `spec/lib/declare_schema/migration_generator_spec.rb:64`
|
|
29
|
+
|
|
30
|
+
**Interfaces:**
|
|
31
|
+
- Produces: `::DeclareSchema.ignore_tables` / `::DeclareSchema.ignore_tables=` (Array, default `[]`)
|
|
32
|
+
- Produces: `::DeclareSchema.ignore_models` / `::DeclareSchema.ignore_models=` (Array, default `[]`)
|
|
33
|
+
- Produces (deprecated but functional): `Generators::DeclareSchema::Migration::Migrator.ignore_tables` / `.ignore_tables=` / `.ignore_models` / `.ignore_models=`, all delegating to the `::DeclareSchema` versions above and emitting an `ActiveSupport::Deprecation` warning.
|
|
34
|
+
|
|
35
|
+
- [ ] **Step 1: Write the failing tests for the new deprecation behavior**
|
|
36
|
+
|
|
37
|
+
In `spec/lib/generators/declare_schema/migration/migrator_spec.rb`, insert these two new `describe` blocks immediately after the existing `describe '#default_collation'` block (which ends right before `describe '#load_rails_models'` at line 59):
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
describe '#ignore_tables' do
|
|
41
|
+
subject { described_class.ignore_tables }
|
|
42
|
+
|
|
43
|
+
context 'when not explicitly set' do
|
|
44
|
+
it { should eq([]) }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when explicitly set' do
|
|
48
|
+
before { described_class.ignore_tables = ["green_fishes"] }
|
|
49
|
+
after { described_class.ignore_tables = [] }
|
|
50
|
+
it { should eq(["green_fishes"]) }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'should output deprecation warning' do
|
|
54
|
+
expect { described_class.ignore_tables = ["green_fishes"] }.to output(/DEPRECATION WARNING: ignore_tables= is deprecated/).to_stderr
|
|
55
|
+
expect { subject }.to output(/DEPRECATION WARNING: ignore_tables is deprecated/).to_stderr
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
after { ::DeclareSchema.ignore_tables = [] }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe '#ignore_models' do
|
|
62
|
+
subject { described_class.ignore_models }
|
|
63
|
+
|
|
64
|
+
context 'when not explicitly set' do
|
|
65
|
+
it { should eq([]) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'when explicitly set' do
|
|
69
|
+
before { described_class.ignore_models = ["Fish"] }
|
|
70
|
+
after { described_class.ignore_models = [] }
|
|
71
|
+
it { should eq(["Fish"]) }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should output deprecation warning' do
|
|
75
|
+
expect { described_class.ignore_models = ["Fish"] }.to output(/DEPRECATION WARNING: ignore_models= is deprecated/).to_stderr
|
|
76
|
+
expect { subject }.to output(/DEPRECATION WARNING: ignore_models is deprecated/).to_stderr
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
after { ::DeclareSchema.ignore_models = [] }
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The outer `after` hooks in each block are a safety net so a failure mid-example (e.g. in the deprecation-warning test, which sets a non-default value but has no matching `after` of its own) can't leak state into later examples/spec files.
|
|
84
|
+
|
|
85
|
+
- [ ] **Step 2: Run the new tests to verify they fail**
|
|
86
|
+
|
|
87
|
+
Run: `bundle exec rspec spec/lib/generators/declare_schema/migration/migrator_spec.rb -e "#ignore_tables" -e "#ignore_models"`
|
|
88
|
+
Expected: FAIL — `NoMethodError: undefined method 'ignore_tables=' for Generators::DeclareSchema::Migration::Migrator` (the setter currently exists as a plain `attr_accessor`, so it won't yet raise a deprecation warning, so the "should output deprecation warning" examples fail with no output matching `/DEPRECATION WARNING/`).
|
|
89
|
+
|
|
90
|
+
- [ ] **Step 3: Add `ignore_tables`/`ignore_models` to `::DeclareSchema`**
|
|
91
|
+
|
|
92
|
+
In `lib/declare_schema.rb`, change:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
@default_charset = "utf8mb4"
|
|
96
|
+
@default_collation = "utf8mb4_bin"
|
|
97
|
+
@default_text_limit = 0xffff_ffff
|
|
98
|
+
@default_string_limit = nil
|
|
99
|
+
@default_null = false
|
|
100
|
+
@default_generate_foreign_keys = true
|
|
101
|
+
@default_generate_indexing = true
|
|
102
|
+
@db_migrate_command = "bundle exec rails db:migrate"
|
|
103
|
+
|
|
104
|
+
class << self
|
|
105
|
+
attr_writer :mysql_version
|
|
106
|
+
attr_reader :default_text_limit, :default_string_limit, :default_null,
|
|
107
|
+
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
to:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
@default_charset = "utf8mb4"
|
|
114
|
+
@default_collation = "utf8mb4_bin"
|
|
115
|
+
@default_text_limit = 0xffff_ffff
|
|
116
|
+
@default_string_limit = nil
|
|
117
|
+
@default_null = false
|
|
118
|
+
@default_generate_foreign_keys = true
|
|
119
|
+
@default_generate_indexing = true
|
|
120
|
+
@db_migrate_command = "bundle exec rails db:migrate"
|
|
121
|
+
@ignore_tables = []
|
|
122
|
+
@ignore_models = []
|
|
123
|
+
|
|
124
|
+
class << self
|
|
125
|
+
attr_writer :mysql_version
|
|
126
|
+
attr_accessor :ignore_tables, :ignore_models
|
|
127
|
+
attr_reader :default_text_limit, :default_string_limit, :default_null,
|
|
128
|
+
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- [ ] **Step 4: Delegate and deprecate on `Migrator`, remove its own accessors**
|
|
132
|
+
|
|
133
|
+
In `lib/generators/declare_schema/migration/migrator.rb`, change:
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
@ignore_models = []
|
|
137
|
+
@ignore_tables = []
|
|
138
|
+
@before_generating_migration_callback = nil
|
|
139
|
+
@active_record_class = ActiveRecord::Base
|
|
140
|
+
|
|
141
|
+
class << self
|
|
142
|
+
attr_accessor :ignore_models, :ignore_tables
|
|
143
|
+
attr_reader :active_record_class, :before_generating_migration_callback
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
to:
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
@before_generating_migration_callback = nil
|
|
150
|
+
@active_record_class = ActiveRecord::Base
|
|
151
|
+
|
|
152
|
+
class << self
|
|
153
|
+
attr_reader :active_record_class, :before_generating_migration_callback
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then change:
|
|
157
|
+
|
|
158
|
+
```ruby
|
|
159
|
+
delegate :default_charset=, :default_collation=, :default_charset, :default_collation, to: ::DeclareSchema
|
|
160
|
+
deprecate :default_charset=, :default_collation=, :default_charset, :default_collation, deprecator: ActiveSupport::Deprecation.new('1.0', 'declare_schema')
|
|
161
|
+
end
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
to:
|
|
165
|
+
|
|
166
|
+
```ruby
|
|
167
|
+
delegate :default_charset=, :default_collation=, :default_charset, :default_collation,
|
|
168
|
+
:ignore_tables=, :ignore_tables, :ignore_models=, :ignore_models, to: ::DeclareSchema
|
|
169
|
+
deprecate :default_charset=, :default_collation=, :default_charset, :default_collation,
|
|
170
|
+
:ignore_tables=, :ignore_tables, :ignore_models=, :ignore_models,
|
|
171
|
+
deprecator: ActiveSupport::Deprecation.new('1.0', 'declare_schema')
|
|
172
|
+
end
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- [ ] **Step 5: Update the internal caller to avoid triggering the new deprecation warning**
|
|
176
|
+
|
|
177
|
+
Still in `lib/generators/declare_schema/migration/migrator.rb`, in `models_and_tables`, change:
|
|
178
|
+
|
|
179
|
+
```ruby
|
|
180
|
+
def models_and_tables
|
|
181
|
+
ignore_model_names = Migrator.ignore_models.map { |model| model.to_s.underscore }
|
|
182
|
+
all_models = table_model_classes
|
|
183
|
+
declare_schema_models = all_models.select do |m|
|
|
184
|
+
(m.name['HABTM_'] ||
|
|
185
|
+
(m.include_in_migration if m.respond_to?(:include_in_migration))) && !m.name.underscore.in?(ignore_model_names)
|
|
186
|
+
end
|
|
187
|
+
non_declare_schema_models = all_models - declare_schema_models
|
|
188
|
+
db_tables = connection.tables - Migrator.ignore_tables.map(&:to_s) - non_declare_schema_models.map(&:table_name)
|
|
189
|
+
[declare_schema_models, db_tables]
|
|
190
|
+
end
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
to:
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
def models_and_tables
|
|
197
|
+
ignore_model_names = ::DeclareSchema.ignore_models.map { |model| model.to_s.underscore }
|
|
198
|
+
all_models = table_model_classes
|
|
199
|
+
declare_schema_models = all_models.select do |m|
|
|
200
|
+
(m.name['HABTM_'] ||
|
|
201
|
+
(m.include_in_migration if m.respond_to?(:include_in_migration))) && !m.name.underscore.in?(ignore_model_names)
|
|
202
|
+
end
|
|
203
|
+
non_declare_schema_models = all_models - declare_schema_models
|
|
204
|
+
db_tables = connection.tables - ::DeclareSchema.ignore_tables.map(&:to_s) - non_declare_schema_models.map(&:table_name)
|
|
205
|
+
[declare_schema_models, db_tables]
|
|
206
|
+
end
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
- [ ] **Step 6: Run the new tests to verify they pass**
|
|
210
|
+
|
|
211
|
+
Run: `bundle exec rspec spec/lib/generators/declare_schema/migration/migrator_spec.rb -e "#ignore_tables" -e "#ignore_models"`
|
|
212
|
+
Expected: PASS (6 examples, 0 failures)
|
|
213
|
+
|
|
214
|
+
- [ ] **Step 7: Update the pre-existing spec that used the now-deprecated setter**
|
|
215
|
+
|
|
216
|
+
In `spec/lib/declare_schema/migration_generator_spec.rb:64`, change:
|
|
217
|
+
|
|
218
|
+
```ruby
|
|
219
|
+
Generators::DeclareSchema::Migration::Migrator.ignore_tables = ["green_fishes"]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
to:
|
|
223
|
+
|
|
224
|
+
```ruby
|
|
225
|
+
::DeclareSchema.ignore_tables = ["green_fishes"]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This avoids emitting an unrelated deprecation warning every time this (large, pre-existing) integration test runs.
|
|
229
|
+
|
|
230
|
+
- [ ] **Step 8: Run the full test suite**
|
|
231
|
+
|
|
232
|
+
Run: `bundle exec rspec`
|
|
233
|
+
Expected: All examples pass, 0 failures (same pass count as before this task, plus the 6 new examples from Step 1).
|
|
234
|
+
|
|
235
|
+
- [ ] **Step 9: Run Rubocop**
|
|
236
|
+
|
|
237
|
+
Run: `bundle exec rubocop lib/declare_schema.rb lib/generators/declare_schema/migration/migrator.rb spec/lib/generators/declare_schema/migration/migrator_spec.rb spec/lib/declare_schema/migration_generator_spec.rb`
|
|
238
|
+
Expected: No offenses.
|
|
239
|
+
|
|
240
|
+
- [ ] **Step 10: Commit**
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
git add lib/declare_schema.rb lib/generators/declare_schema/migration/migrator.rb spec/lib/generators/declare_schema/migration/migrator_spec.rb spec/lib/declare_schema/migration_generator_spec.rb
|
|
244
|
+
git commit -m "OCTO-893: Deprecate Migrator.ignore_tables/ignore_models
|
|
245
|
+
|
|
246
|
+
Move ignore_tables and ignore_models to ::DeclareSchema, following the
|
|
247
|
+
same delegate+deprecate pattern already used for default_charset and
|
|
248
|
+
default_collation. The Migrator accessors keep working but emit an
|
|
249
|
+
ActiveSupport deprecation warning; nothing is removed."
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### Task 2: Document the new settings in the README
|
|
255
|
+
|
|
256
|
+
**Files:**
|
|
257
|
+
- Modify: `README.md:377-394` (existing "Ignored Tables" section)
|
|
258
|
+
|
|
259
|
+
**Interfaces:**
|
|
260
|
+
- Consumes: `::DeclareSchema.ignore_tables` / `::DeclareSchema.ignore_models` from Task 1 (must already exist and work).
|
|
261
|
+
|
|
262
|
+
- [ ] **Step 1: Update the "Ignored Tables" section and add a new "Ignored Models" section**
|
|
263
|
+
|
|
264
|
+
In `README.md`, change:
|
|
265
|
+
|
|
266
|
+
```markdown
|
|
267
|
+
## Ignored Tables
|
|
268
|
+
If a table's schema or metadata are managed elsewhere, `declare_schema` can be instructed to ignore it
|
|
269
|
+
by adding those table names to the array assigned to `Generators::DeclareSchema::Migration::Migrator.ignore_tables`.
|
|
270
|
+
For example:
|
|
271
|
+
|
|
272
|
+
```ruby
|
|
273
|
+
::Generators::DeclareSchema::Migration::Migrator.ignore_tables = [
|
|
274
|
+
"delayed_jobs",
|
|
275
|
+
"my_snowflake_table",
|
|
276
|
+
...
|
|
277
|
+
]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Note: `declare_schema` always ignores these tables:
|
|
281
|
+
- The ActiveRecord `schema_info` table
|
|
282
|
+
- The ActiveRecord schema migrations table (generally named `schema_migrations`)
|
|
283
|
+
- The ActiveRecord internal metadata table (generally named `ar_internal_metadata`)
|
|
284
|
+
- If defined/configured, the CGI ActiveRecordStore session table
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
to:
|
|
288
|
+
|
|
289
|
+
```markdown
|
|
290
|
+
## Ignored Tables
|
|
291
|
+
If a table's schema or metadata are managed elsewhere, `declare_schema` can be instructed to ignore it
|
|
292
|
+
by adding those table names to the array assigned to `DeclareSchema.ignore_tables`.
|
|
293
|
+
For example:
|
|
294
|
+
|
|
295
|
+
```ruby
|
|
296
|
+
::DeclareSchema.ignore_tables = [
|
|
297
|
+
"delayed_jobs",
|
|
298
|
+
"my_snowflake_table",
|
|
299
|
+
...
|
|
300
|
+
]
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Deprecated:** `Generators::DeclareSchema::Migration::Migrator.ignore_tables` is a deprecated alias for
|
|
304
|
+
`DeclareSchema.ignore_tables` above. It still works, but new code should use `DeclareSchema.ignore_tables`
|
|
305
|
+
directly.
|
|
306
|
+
|
|
307
|
+
Note: `declare_schema` always ignores these tables:
|
|
308
|
+
- The ActiveRecord `schema_info` table
|
|
309
|
+
- The ActiveRecord schema migrations table (generally named `schema_migrations`)
|
|
310
|
+
- The ActiveRecord internal metadata table (generally named `ar_internal_metadata`)
|
|
311
|
+
- If defined/configured, the CGI ActiveRecordStore session table
|
|
312
|
+
|
|
313
|
+
## Ignored Models
|
|
314
|
+
Similarly, `declare_schema` can be instructed to ignore specific models (so that no migration is
|
|
315
|
+
generated for their table) by adding the model's underscored name to the array assigned to
|
|
316
|
+
`DeclareSchema.ignore_models`. For example:
|
|
317
|
+
|
|
318
|
+
```ruby
|
|
319
|
+
::DeclareSchema.ignore_models = [
|
|
320
|
+
"my_legacy_model",
|
|
321
|
+
...
|
|
322
|
+
]
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Deprecated:** `Generators::DeclareSchema::Migration::Migrator.ignore_models` is a deprecated alias for
|
|
326
|
+
`DeclareSchema.ignore_models` above. It still works, but new code should use `DeclareSchema.ignore_models`
|
|
327
|
+
directly.
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
- [ ] **Step 2: Verify the README's fenced code blocks are balanced**
|
|
331
|
+
|
|
332
|
+
Run: `grep -c '^```' README.md`
|
|
333
|
+
Expected: An even number (each opened fence is closed).
|
|
334
|
+
|
|
335
|
+
- [ ] **Step 3: Commit**
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
git add README.md
|
|
339
|
+
git commit -m "OCTO-893: Document DeclareSchema.ignore_tables and ignore_models
|
|
340
|
+
|
|
341
|
+
Update the README's Ignored Tables section to point at the new public
|
|
342
|
+
DeclareSchema.ignore_tables setting, and add a new Ignored Models
|
|
343
|
+
section documenting DeclareSchema.ignore_models. Both note that the
|
|
344
|
+
old Migrator-based settings are deprecated aliases."
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
### Task 3: Bump version and update CHANGELOG
|
|
350
|
+
|
|
351
|
+
**Files:**
|
|
352
|
+
- Modify: `lib/declare_schema/version.rb`
|
|
353
|
+
- Modify: `Gemfile.lock`
|
|
354
|
+
- Modify: `CHANGELOG.md`
|
|
355
|
+
|
|
356
|
+
**Interfaces:**
|
|
357
|
+
- Consumes: nothing new — this is a release-metadata-only task, done after Tasks 1 and 2 are committed.
|
|
358
|
+
|
|
359
|
+
- [ ] **Step 1: Bump the version**
|
|
360
|
+
|
|
361
|
+
In `lib/declare_schema/version.rb`, change:
|
|
362
|
+
|
|
363
|
+
```ruby
|
|
364
|
+
module DeclareSchema
|
|
365
|
+
VERSION = "4.0.3"
|
|
366
|
+
end
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
to:
|
|
370
|
+
|
|
371
|
+
```ruby
|
|
372
|
+
module DeclareSchema
|
|
373
|
+
VERSION = "4.1.0"
|
|
374
|
+
end
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
- [ ] **Step 2: Update Gemfile.lock**
|
|
378
|
+
|
|
379
|
+
Run: `bundle install`
|
|
380
|
+
Expected: `Gemfile.lock`'s `PATH` section updates from `declare_schema (4.0.3)` to `declare_schema (4.1.0)`, and the `DEPENDENCIES`/lockfile line for `declare_schema (= 4.1.0)` (if present) updates to match.
|
|
381
|
+
|
|
382
|
+
- [ ] **Step 3: Add the CHANGELOG entry**
|
|
383
|
+
|
|
384
|
+
In `CHANGELOG.md`, change:
|
|
385
|
+
|
|
386
|
+
```markdown
|
|
387
|
+
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
388
|
+
|
|
389
|
+
## [4.0.3] - 2026-07-01
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
to (using today's actual date when this step is executed):
|
|
393
|
+
|
|
394
|
+
```markdown
|
|
395
|
+
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
396
|
+
|
|
397
|
+
## [4.1.0] - 2026-07-03
|
|
398
|
+
### Added
|
|
399
|
+
- `::DeclareSchema.ignore_tables` and `::DeclareSchema.ignore_models` as the new public
|
|
400
|
+
settings for ignoring tables/models during migration generation.
|
|
401
|
+
|
|
402
|
+
### Deprecated
|
|
403
|
+
- `Generators::DeclareSchema::Migration::Migrator.ignore_tables` and `.ignore_models` in
|
|
404
|
+
favor of `DeclareSchema.ignore_tables` and `DeclareSchema.ignore_models` above. The
|
|
405
|
+
`Migrator` accessors still work but emit a deprecation warning; they will not be
|
|
406
|
+
removed without a major version bump.
|
|
407
|
+
|
|
408
|
+
## [4.0.3] - 2026-07-01
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
- [ ] **Step 4: Run the full test suite one more time**
|
|
412
|
+
|
|
413
|
+
Run: `bundle exec rspec`
|
|
414
|
+
Expected: All examples pass, 0 failures.
|
|
415
|
+
|
|
416
|
+
- [ ] **Step 5: Commit**
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
git add lib/declare_schema/version.rb Gemfile.lock CHANGELOG.md
|
|
420
|
+
git commit -m "Bump version to 4.1.0
|
|
421
|
+
|
|
422
|
+
Adds DeclareSchema.ignore_tables/ignore_models (OCTO-893), deprecating
|
|
423
|
+
the old Migrator-based settings without removing them."
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## After This Plan
|
|
429
|
+
|
|
430
|
+
- Do **not** push the branch, open a PR, or run `rake release` — those are explicit go/no-go decisions for the user, out of scope for this plan.
|
|
431
|
+
- Once the user reviews the local commits, they can decide whether to push `OCTO-893/deprecate-migrator-ignore-tables` and open a PR.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Design: Deprecate `Migrator.ignore_tables`/`ignore_models` in favor of `DeclareSchema.ignore_tables`/`ignore_models`
|
|
2
|
+
|
|
3
|
+
Jira: [OCTO-893](https://invoca.atlassian.net/browse/OCTO-893)
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
`declare_schema`'s ignore-tables and ignore-models settings are currently configured
|
|
8
|
+
through an internal implementation class:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
::Generators::DeclareSchema::Migration::Migrator.ignore_tables = [...]
|
|
12
|
+
::Generators::DeclareSchema::Migration::Migrator.ignore_models = [...]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This leaks an internal `Migrator` class as public config API, inconsistent with the
|
|
16
|
+
gem's public `DeclareSchema` namespace. The two settings are exact parallels of each
|
|
17
|
+
other in the current code — same declaration, same init pattern, same usage style —
|
|
18
|
+
so this design treats them identically.
|
|
19
|
+
|
|
20
|
+
## Precedent
|
|
21
|
+
|
|
22
|
+
This exact situation was already solved once before, for `default_charset` and
|
|
23
|
+
`default_collation`, back in v0.10.0 (see `CHANGELOG.md`):
|
|
24
|
+
|
|
25
|
+
> Moved and deprecated default settings for `default_charset` and `default_collation`
|
|
26
|
+
> from `Generators::DeclareSchema::Migration::Migrator` to `::DeclareSchema`
|
|
27
|
+
|
|
28
|
+
The implementation lives in
|
|
29
|
+
`lib/generators/declare_schema/migration/migrator.rb`:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
delegate :default_charset=, :default_collation=, :default_charset, :default_collation, to: ::DeclareSchema
|
|
33
|
+
deprecate :default_charset=, :default_collation=, :default_charset, :default_collation, deprecator: ActiveSupport::Deprecation.new('1.0', 'declare_schema')
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This design reuses that same pattern for both `ignore_tables` and `ignore_models`.
|
|
37
|
+
|
|
38
|
+
## Design
|
|
39
|
+
|
|
40
|
+
1. **`lib/declare_schema.rb`**
|
|
41
|
+
- Add `@ignore_tables = []` and `@ignore_models = []` to the module's default instance
|
|
42
|
+
variables.
|
|
43
|
+
- Add `:ignore_tables, :ignore_models` to the module's `attr_accessor` list in `class << self`.
|
|
44
|
+
|
|
45
|
+
2. **`lib/generators/declare_schema/migration/migrator.rb`**
|
|
46
|
+
- Remove `attr_accessor :ignore_models, :ignore_tables` entirely from `Migrator` (both
|
|
47
|
+
settings move to `::DeclareSchema`; nothing is left behind on `Migrator`).
|
|
48
|
+
- Add `:ignore_tables=, :ignore_tables, :ignore_models=, :ignore_models` to the existing
|
|
49
|
+
`delegate ... to: ::DeclareSchema` line.
|
|
50
|
+
- Add the same four methods to the existing `deprecate ...` line, reusing the same
|
|
51
|
+
`ActiveSupport::Deprecation.new('1.0', 'declare_schema')` instance (no new deprecator).
|
|
52
|
+
- Update the two internal callers in `models_and_tables` (currently `Migrator.ignore_tables`
|
|
53
|
+
at line ~111 and `Migrator.ignore_models` at line ~104) to call `::DeclareSchema.ignore_tables`
|
|
54
|
+
/ `::DeclareSchema.ignore_models` directly, so normal migration generation doesn't trigger a
|
|
55
|
+
deprecation warning on every run — matching how `default_charset`/`default_collation` are
|
|
56
|
+
already called directly via `::DeclareSchema` elsewhere in this file.
|
|
57
|
+
|
|
58
|
+
3. **Tests** — `spec/lib/generators/declare_schema/migration/migrator_spec.rb`
|
|
59
|
+
- Add `#ignore_tables` and `#ignore_models` describe blocks mirroring the existing
|
|
60
|
+
`#default_charset` block: value passthrough (default `[]`, explicit set/reset) and
|
|
61
|
+
deprecation-warning assertions for both the reader and writer of each.
|
|
62
|
+
- Update `spec/lib/declare_schema/migration_generator_spec.rb` (the one existing spec that
|
|
63
|
+
sets `Generators::DeclareSchema::Migration::Migrator.ignore_tables = ["green_fishes"]`)
|
|
64
|
+
to use `::DeclareSchema.ignore_tables = [...]` instead, so that unrelated test doesn't
|
|
65
|
+
emit deprecation noise.
|
|
66
|
+
|
|
67
|
+
4. **README.md**
|
|
68
|
+
- Update the existing "Ignored Tables" section: primary documented setting becomes
|
|
69
|
+
`::DeclareSchema.ignore_tables`, with a note that `Migrator.ignore_tables` is deprecated
|
|
70
|
+
(still works, not removed).
|
|
71
|
+
- Add a new "Ignored Models" section (not previously documented) covering
|
|
72
|
+
`::DeclareSchema.ignore_models`, with the same deprecation note for
|
|
73
|
+
`Migrator.ignore_models`.
|
|
74
|
+
|
|
75
|
+
5. **CHANGELOG.md**
|
|
76
|
+
- New `## [4.1.0]` entry:
|
|
77
|
+
- `### Added` — `::DeclareSchema.ignore_tables` and `::DeclareSchema.ignore_models` as
|
|
78
|
+
the new public settings.
|
|
79
|
+
- `### Deprecated` — `Generators::DeclareSchema::Migration::Migrator.ignore_tables` and
|
|
80
|
+
`.ignore_models` in favor of the above; still function, will not be removed without a
|
|
81
|
+
major version bump.
|
|
82
|
+
|
|
83
|
+
6. **Versioning**
|
|
84
|
+
- Bump `4.0.3` → `4.1.0` (minor: new backward-compatible public API + non-breaking
|
|
85
|
+
deprecation, nothing removed).
|
|
86
|
+
- Separate commit touching only `lib/declare_schema/version.rb`, `Gemfile.lock`,
|
|
87
|
+
`CHANGELOG.md`, matching the repo's existing release-commit convention (see `40f47e3`).
|
|
88
|
+
|
|
89
|
+
## Out of Scope
|
|
90
|
+
|
|
91
|
+
- No changes to any application code that consumes this gem (follow-up, not part of this ticket).
|
|
92
|
+
- No gem release / publish — implementation + local commits only, pending explicit
|
|
93
|
+
go-ahead to push/release.
|
|
94
|
+
|
|
95
|
+
## Testing Plan
|
|
96
|
+
|
|
97
|
+
- Unit tests per above (delegation + deprecation warning) for both settings.
|
|
98
|
+
- Full existing spec suite must still pass (`bundle exec rspec`).
|
|
99
|
+
- `bundle exec rubocop` clean.
|
data/lib/declare_schema.rb
CHANGED
|
@@ -32,10 +32,12 @@ module DeclareSchema
|
|
|
32
32
|
@default_generate_foreign_keys = true
|
|
33
33
|
@default_generate_indexing = true
|
|
34
34
|
@db_migrate_command = "bundle exec rails db:migrate"
|
|
35
|
+
@ignore_tables = []
|
|
36
|
+
@ignore_models = []
|
|
35
37
|
|
|
36
38
|
class << self
|
|
37
39
|
attr_writer :mysql_version
|
|
38
|
-
attr_reader :default_text_limit, :default_string_limit, :default_null,
|
|
40
|
+
attr_reader :ignore_tables, :ignore_models, :default_text_limit, :default_string_limit, :default_null,
|
|
39
41
|
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
|
|
40
42
|
|
|
41
43
|
def to_class(type)
|
|
@@ -122,6 +124,16 @@ module DeclareSchema
|
|
|
122
124
|
@default_generate_indexing = generate_indexing
|
|
123
125
|
end
|
|
124
126
|
|
|
127
|
+
def ignore_tables=(ignore_tables)
|
|
128
|
+
ignore_tables.nil? or ignore_tables.is_a?(Array) or raise ArgumentError, "ignore_tables must be an array or nil (got #{ignore_tables.inspect})"
|
|
129
|
+
@ignore_tables = ignore_tables || []
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def ignore_models=(ignore_models)
|
|
133
|
+
ignore_models.nil? or ignore_models.is_a?(Array) or raise ArgumentError, "ignore_models must be an array or nil (got #{ignore_models.inspect})"
|
|
134
|
+
@ignore_models = ignore_models || []
|
|
135
|
+
end
|
|
136
|
+
|
|
125
137
|
def default_schema(&block)
|
|
126
138
|
if block.nil?
|
|
127
139
|
@default_schema # equivalent to attr_reader :default_schema
|
|
@@ -11,13 +11,10 @@ module Generators
|
|
|
11
11
|
class Migrator
|
|
12
12
|
class Error < RuntimeError; end
|
|
13
13
|
|
|
14
|
-
@ignore_models = []
|
|
15
|
-
@ignore_tables = []
|
|
16
14
|
@before_generating_migration_callback = nil
|
|
17
15
|
@active_record_class = ActiveRecord::Base
|
|
18
16
|
|
|
19
17
|
class << self
|
|
20
|
-
attr_accessor :ignore_models, :ignore_tables
|
|
21
18
|
attr_reader :active_record_class, :before_generating_migration_callback
|
|
22
19
|
|
|
23
20
|
def active_record_class
|
|
@@ -43,8 +40,11 @@ module Generators
|
|
|
43
40
|
@before_generating_migration_callback = block
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
delegate :default_charset=, :default_collation=, :default_charset, :default_collation,
|
|
47
|
-
|
|
43
|
+
delegate :default_charset=, :default_collation=, :default_charset, :default_collation,
|
|
44
|
+
:ignore_tables=, :ignore_tables, :ignore_models=, :ignore_models, to: ::DeclareSchema
|
|
45
|
+
deprecate :default_charset=, :default_collation=, :default_charset, :default_collation,
|
|
46
|
+
:ignore_tables=, :ignore_tables, :ignore_models=, :ignore_models,
|
|
47
|
+
deprecator: ActiveSupport::Deprecation.new('5.0', 'declare_schema')
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def initialize(renames: nil, &block)
|
|
@@ -101,14 +101,14 @@ module Generators
|
|
|
101
101
|
# Returns an array of model classes and an array of table names
|
|
102
102
|
# that generation needs to take into account
|
|
103
103
|
def models_and_tables
|
|
104
|
-
ignore_model_names =
|
|
104
|
+
ignore_model_names = ::DeclareSchema.ignore_models.map { |model| model.to_s.underscore }
|
|
105
105
|
all_models = table_model_classes
|
|
106
106
|
declare_schema_models = all_models.select do |m|
|
|
107
107
|
(m.name['HABTM_'] ||
|
|
108
108
|
(m.include_in_migration if m.respond_to?(:include_in_migration))) && !m.name.underscore.in?(ignore_model_names)
|
|
109
109
|
end
|
|
110
110
|
non_declare_schema_models = all_models - declare_schema_models
|
|
111
|
-
db_tables = connection.tables -
|
|
111
|
+
db_tables = connection.tables - ::DeclareSchema.ignore_tables.map(&:to_s) - non_declare_schema_models.map(&:table_name)
|
|
112
112
|
[declare_schema_models, db_tables]
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -51,6 +51,8 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
context 'Using declare_schema' do
|
|
54
|
+
after { ::DeclareSchema.ignore_tables = [] }
|
|
55
|
+
|
|
54
56
|
# DeclareSchema - Migration Generator
|
|
55
57
|
it 'generates migrations' do
|
|
56
58
|
## The migration generator -- introduction
|
|
@@ -61,7 +63,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
|
61
63
|
|
|
62
64
|
expect(Generators::DeclareSchema::Migration::Migrator.run).to migrate_up("").and migrate_down("")
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
::DeclareSchema.ignore_tables = ["green_fishes"]
|
|
65
67
|
|
|
66
68
|
Advert.connection.schema_cache.clear!
|
|
67
69
|
Advert.reset_column_information
|
|
@@ -193,6 +193,58 @@ RSpec.describe DeclareSchema do
|
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
+
describe '#ignore_tables' do
|
|
197
|
+
subject { described_class.ignore_tables }
|
|
198
|
+
|
|
199
|
+
context 'when not explicitly set' do
|
|
200
|
+
it { is_expected.to eq([]) }
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
context 'when explicitly set to an array' do
|
|
204
|
+
before { described_class.ignore_tables = ["green_fishes"] }
|
|
205
|
+
after { described_class.ignore_tables = [] }
|
|
206
|
+
it { is_expected.to eq(["green_fishes"]) }
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
context 'when explicitly set to nil' do
|
|
210
|
+
before { described_class.ignore_tables = nil }
|
|
211
|
+
after { described_class.ignore_tables = [] }
|
|
212
|
+
it { is_expected.to eq([]) }
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
context 'when set to a non-Array' do
|
|
216
|
+
it 'raises ArgumentError' do
|
|
217
|
+
expect { described_class.ignore_tables = "green_fishes" }.to raise_error(ArgumentError, /ignore_tables must be an array or nil/)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
describe '#ignore_models' do
|
|
223
|
+
subject { described_class.ignore_models }
|
|
224
|
+
|
|
225
|
+
context 'when not explicitly set' do
|
|
226
|
+
it { is_expected.to eq([]) }
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
context 'when explicitly set to an array' do
|
|
230
|
+
before { described_class.ignore_models = ["Fish"] }
|
|
231
|
+
after { described_class.ignore_models = [] }
|
|
232
|
+
it { is_expected.to eq(["Fish"]) }
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context 'when explicitly set to nil' do
|
|
236
|
+
before { described_class.ignore_models = nil }
|
|
237
|
+
after { described_class.ignore_models = [] }
|
|
238
|
+
it { is_expected.to eq([]) }
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
context 'when set to a non-Array' do
|
|
242
|
+
it 'raises ArgumentError' do
|
|
243
|
+
expect { described_class.ignore_models = "Fish" }.to raise_error(ArgumentError, /ignore_models must be an array or nil/)
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
196
248
|
describe '#max_index_and_constraint_name_length' do
|
|
197
249
|
subject { described_class.max_index_and_constraint_name_length }
|
|
198
250
|
|
|
@@ -56,6 +56,48 @@ module Generators
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
describe '#ignore_tables' do
|
|
60
|
+
subject { described_class.ignore_tables }
|
|
61
|
+
|
|
62
|
+
context 'when not explicitly set' do
|
|
63
|
+
it { should eq([]) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context 'when explicitly set' do
|
|
67
|
+
before { described_class.ignore_tables = ["green_fishes"] }
|
|
68
|
+
after { described_class.ignore_tables = [] }
|
|
69
|
+
it { should eq(["green_fishes"]) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'should output deprecation warning' do
|
|
73
|
+
expect { described_class.ignore_tables = ["green_fishes"] }.to output(/DEPRECATION WARNING: ignore_tables= is deprecated/).to_stderr
|
|
74
|
+
expect { subject }.to output(/DEPRECATION WARNING: ignore_tables is deprecated/).to_stderr
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
after { ::DeclareSchema.ignore_tables = [] }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '#ignore_models' do
|
|
81
|
+
subject { described_class.ignore_models }
|
|
82
|
+
|
|
83
|
+
context 'when not explicitly set' do
|
|
84
|
+
it { should eq([]) }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'when explicitly set' do
|
|
88
|
+
before { described_class.ignore_models = ["Fish"] }
|
|
89
|
+
after { described_class.ignore_models = [] }
|
|
90
|
+
it { should eq(["Fish"]) }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'should output deprecation warning' do
|
|
94
|
+
expect { described_class.ignore_models = ["Fish"] }.to output(/DEPRECATION WARNING: ignore_models= is deprecated/).to_stderr
|
|
95
|
+
expect { subject }.to output(/DEPRECATION WARNING: ignore_models is deprecated/).to_stderr
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
after { ::DeclareSchema.ignore_models = [] }
|
|
99
|
+
end
|
|
100
|
+
|
|
59
101
|
describe '#load_rails_models' do
|
|
60
102
|
before do
|
|
61
103
|
expect(Rails.application).to receive(:eager_load!)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: declare_schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
|
@@ -55,6 +55,8 @@ files:
|
|
|
55
55
|
- catalog-info.yaml
|
|
56
56
|
- config/brakeman.ignore
|
|
57
57
|
- declare_schema.gemspec
|
|
58
|
+
- docs/superpowers/plans/2026-07-03-ignore-tables-ignore-models-deprecation.md
|
|
59
|
+
- docs/superpowers/specs/2026-07-03-ignore-tables-deprecation-design.md
|
|
58
60
|
- gemfiles/.bundle/config
|
|
59
61
|
- gemfiles/rails_7_0.gemfile
|
|
60
62
|
- gemfiles/rails_7_1.gemfile
|