@@ -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```
9798bundle 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.
217219Note that a unique index can _ never be replaced by a non-unique one_ . For
218220example, 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
222228Supported configuration options:
223229
@@ -230,7 +236,8 @@ Supported configuration options:
230236If you soft-delete some models (e.g. with ` paranoia ` ) then you need to modify
231237your indexes to include only non-deleted rows. Otherwise they will include
232238logically 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.
316326Supported 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
327338In 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
349361If 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
352365In 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
0 commit comments