Skip to content

Commit 4096828

Browse files
committed
Release 1.10.0
1 parent 738f695 commit 4096828

File tree

3 files changed

+74
-20
lines changed

3 files changed

+74
-20
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
# Version 1.10.0
2+
3+
* New feature: incorrect_length_validation detector can identify text-column
4+
length mismatches between tables and models (suggested by fatkodima).
5+
* New feature: each detector can be enabled or disabled globally via the
6+
configuration file.
7+
* Enhancement: missing_non_null_constraints and missing_presence_validation
8+
recognized NOT NULL check constraints (contributed by fatkodima).
9+
* Enhancement: missing_unique_index is aware of has_one associations and
10+
recommends creating an index on the corresponding foreign key (contributed by
11+
fatkodima).
12+
* Bug fix: missing_unique_indexes can be satisfied by creating an index on a
13+
sublist of scope + column. Previously, it'd not accept such sublists even
14+
though they're enough to guarantee uniqueness (contributed by fatkodima).
15+
* Bug fix: fix missing_unique_indexes crashes on function indexes (contributed
16+
by fatkodima).
17+
* Bug fix: short_primary_key_type no longer complains about UUID primary keys
18+
(contributed by fatkodima).
19+
* Bug fix: extraneous_indexes was made aware of non-standard primary key names
20+
and partial indexes (contributed by fatkodima).
21+
* Bug fix: extraneous_indexes properly recognizes smaller indexes to be enough
22+
to guarantee uniqueness. Previously, it'd skip some smaller indexes and ask
23+
for a larger index to be created (contributed by fatkodima).
24+
* Bug fix: unindexed_deleted_at correctly works on partial indexes intended to
25+
cover deleted columns. It no longer asks to create a contradictory condition
26+
(IS NULL AND IS NOT NULL) in those cases (contributed by fatkodima).
27+
* Bug fix: incorrect_dependent_option works correctly on polymorphic
28+
associations.
29+
* Bug fix: recognize the PostGIS adapter as PostgreSQL (contributed by
30+
fatkodima).
31+
* Bug fix: index generators use index_name_length (defined by Active Record) to
32+
ensure index names aren't too long (contributed by fatkodima).
33+
* Tested against Ruby 3.1 via CI (contributed by Peter Goldstein).
34+
* Documentation fixes (contributed by Alistair McKinnell and Kaleb Lape).
35+
136
# Version 1.9.0
237

338
* New feature: support for project-specific configuration and Continuous

README.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ build steps -- it returns a non-zero exit status if any errors were reported.
9191

9292
### Obtaining Help
9393

94-
If you'd like to obtain help on a specific detector then use the `help` sub-task:
94+
If you'd like to obtain help on a specific detector then use the `help`
95+
sub-task:
9596

9697
```
9798
bundle exec rake active_record_doctor:extraneous_indexes:help
@@ -176,7 +177,8 @@ Supported configuration options:
176177

177178
- `enabled` - set to `false` to disable the detector altogether
178179
- `ignore_tables` - tables whose foreign keys should not be checked
179-
- `ignore_columns` - columns, written as table.column, that should not be checked.
180+
- `ignore_columns` - columns, written as table.column, that should not be
181+
checked.
180182

181183
### Removing Extraneous Indexes
182184

@@ -217,7 +219,11 @@ reported.
217219
Note that a unique index can _never be replaced by a non-unique one_. For
218220
example, if there's a unique index on `users.login` and a non-unique index on
219221
`users.login, users.domain` then the tool will _not_ suggest dropping
220-
`users.login` as it could violate the uniqueness assumption.
222+
`users.login` as it could violate the uniqueness assumption. However, a unique
223+
index on `users.login, user.domain` might be replaceable with `users.login` as
224+
the uniqueness of the latter implies the uniqueness of the former (if a given
225+
`login` can appear only once then it can be present in only one `login, domain`
226+
pair).
221227

222228
Supported configuration options:
223229

@@ -230,7 +236,8 @@ Supported configuration options:
230236
If you soft-delete some models (e.g. with `paranoia`) then you need to modify
231237
your indexes to include only non-deleted rows. Otherwise they will include
232238
logically non-existent rows. This will make them larger and slower to use. Most
233-
of the time they should only cover columns satisfying `deleted_at IS NULL`.
239+
of the time they should only cover columns satisfying `deleted_at IS NULL` (to
240+
cover existing records) or `deleted_at IS NOT NULL` (to cover deleted records).
234241

235242
`active_record_doctor` can automatically detect indexes on tables with a
236243
`deleted_at` column. Just run:
@@ -247,8 +254,10 @@ Supported configuration options:
247254

248255
- `enabled` - set to `false` to disable the detector altogether
249256
- `ignore_tables` - tables whose indexes should not be checked.
250-
- `ignore_columns` - specific columns, written as table.column, that should not be reported as unindexed.
251-
- `ignore_indexes` - specific indexes that should not be reported as excluding a timestamp column.
257+
- `ignore_columns` - specific columns, written as table.column, that should not
258+
be reported as unindexed.
259+
- `ignore_indexes` - specific indexes that should not be reported as excluding a
260+
timestamp column.
252261
- `column_names` - deletion timestamp column names.
253262

254263
### Detecting Missing Foreign Key Constraints
@@ -283,7 +292,8 @@ Supported configuration options:
283292

284293
- `enabled` - set to `false` to disable the detector altogether
285294
- `ignore_tables` - tables whose columns should not be checked.
286-
- `ignore_columns` - columns, written as table.column, that should not be checked.
295+
- `ignore_columns` - columns, written as table.column, that should not be
296+
checked.
287297

288298
### Detecting Models Referencing Undefined Tables
289299

@@ -316,13 +326,14 @@ this check as part of your Continuous Integration pipeline.
316326
Supported configuration options:
317327

318328
- `enabled` - set to `false` to disable the detector altogether
319-
- `ignore_models` - models whose underlying tables should not be checked for existence.
329+
- `ignore_models` - models whose underlying tables should not be checked for
330+
existence.
320331

321332
### Detecting Uniqueness Validations not Backed by an Index
322333

323-
A model-level uniqueness validations should be backed by a database index in
324-
order to be robust. Otherwise you risk inserting duplicate values under heavy
325-
load.
334+
Model-level uniqueness validations and `has_one` associations should be backed
335+
by a database index in order to be robust. Otherwise you risk inserting
336+
duplicate values under heavy load.
326337

327338
In order to detect such validations run:
328339

@@ -342,12 +353,14 @@ Supported configuration options:
342353

343354
- `enabled` - set to `false` to disable the detector altogether
344355
- `ignore_models` - models whose uniqueness validators should not be checked.
345-
- `ignore_columns` - specific validators, written as Model(column1, column2, ...), that should not be checked.
356+
- `ignore_columns` - specific validators, written as Model(column1, ...), that
357+
should not be checked.
346358

347359
### Detecting Missing Non-`NULL` Constraints
348360

349361
If there's an unconditional presence validation on a column then it should be
350-
marked as non-`NULL`-able at the database level.
362+
marked as non-`NULL`-able at the database level or should have a `IS NOT NULL`
363+
constraint.
351364

352365
In order to detect columns whose presence is required but that are marked
353366
`null: true` in the database run the following command:
@@ -371,7 +384,8 @@ Supported configuration options:
371384

372385
- `enabled` - set to `false` to disable the detector altogether
373386
- `ignore_tables` - tables whose columns should not be checked.
374-
- `ignore_columns` - columns, written as table.column, that should not be checked.
387+
- `ignore_columns` - columns, written as table.column, that should not be
388+
checked.
375389

376390
### Detecting Missing Presence Validations
377391

@@ -399,7 +413,8 @@ Supported configuration options:
399413

400414
- `enabled` - set to `false` to disable the detector altogether
401415
- `ignore_models` - models whose underlying tables' columns should not be checked.
402-
- `ignore_attributes` - specific attributes, written as Model.attribute, that should not be checked.
416+
- `ignore_attributes` - specific attributes, written as Model.attribute, that
417+
should not be checked.
403418

404419
### Detecting Incorrect Presence Validations on Boolean Columns
405420

@@ -427,7 +442,8 @@ Supported configuration options:
427442

428443
- `enabled` - set to `false` to disable the detector altogether
429444
- `ignore_models` - models whose validators should not be checked.
430-
- `ignore_columns` - attributes, written as Model.attribute, whose validators should not be checked.
445+
- `ignore_columns` - attributes, written as Model.attribute, whose validators
446+
should not be checked.
431447

432448
### Detecting Incorrect Length Validations
433449

@@ -459,7 +475,8 @@ Supported configuration options:
459475

460476
- `enabled` - set to `false` to disable the detector altogether
461477
- `ignore_models` - models whose validators should not be checked.
462-
- `ignore_columns` - attributes, written as Model.attribute, whose validators should not be checked.
478+
- `ignore_columns` - attributes, written as Model.attribute, whose validators
479+
should not be checked.
463480

464481
### Detecting Incorrect `dependent` Option on Associations
465482

@@ -492,7 +509,8 @@ Supported configuration options:
492509

493510
- `enabled` - set to `false` to disable the detector altogether
494511
- `ignore_models` - models whose associations should not be checked.
495-
- `ignore_columns` - associations, written as Model.association, that should not be checked.
512+
- `ignore_columns` - associations, written as Model.association, that should not
513+
be checked.
496514

497515
### Detecting Primary Keys Having Short Integer Types
498516

@@ -554,7 +572,8 @@ Supported configuration options:
554572

555573
- `enabled` - set to `false` to disable the detector altogether
556574
- `ignore_tables` - tables whose foreign keys should not be checked.
557-
- `ignore_columns` - foreign keys, written as table.column, that should not be checked.
575+
- `ignore_columns` - foreign keys, written as table.column, that should not be
576+
checked.
558577

559578
## Ruby and Rails Compatibility Policy
560579

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ActiveRecordDoctor
4-
VERSION = "1.9.0"
4+
VERSION = "1.10.0"
55
end

0 commit comments

Comments
 (0)