incident_components keeps an index that the July composite unique now covers
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start by reading 2017_07_18_214718_CreateIncidentComponents.php and 2026_07_25_000002_add_constraints_to_component_pivots.php, then run the schema checks with Laravel Truss's truss:doctor. Determine the migration path for existing installs and the fresh-install schema change. Done means incident_components no longer has the redundant single-column index while the composite unique remains intact.
Written by the indexing model from the issue text.
Description
incident_components has a single column index on incident_id, from 2017_07_18_214718_CreateIncidentComponents.php:
$table->integer('incident_id')->unsigned()->index();
Since 2026_07_25_000002_add_constraints_to_component_pivots.php added the unique on (incident_id, component_id), that older index is a left prefix of the unique. MySQL and PostgreSQL can both answer a query filtering on incident_id alone from the composite, so the single column index no longer adds a read path. It is still maintained on every insert and update to the pivot, and still takes space.
Nothing here was written wrong. The composite arrived nine years after the single index, which is the ordinary way this happens.
schedule_components is not affected. It was constrained in the same migration, but its 2016 migration adds no single column indexes, so there is nothing to remove there.
The fix is to drop the index. An existing install needs a follow up migration; for new installs it is removing ->index() from the 2017 migration, though you may prefer not to edit a historical one.
Found with Laravel Truss, a structure only schema linter, running truss:doctor against a Cachet install. Checked against main today.
- Dominant language
- PHP
- Stars
- 228
- Forks
- 84
- Avg merge
- 11h 19m
- Merged PRs (30d)
- 22
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cachethq/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Banner image upload fails with "The banner image field contains a file path that is not permitted" Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
filament
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·