Skip to content

fix(migration): assign explicit name to custom_object_records linked index#63

Merged
mpge merged 2 commits intomasterfrom
fix/custom-object-records-index-name
May 6, 2026
Merged

fix(migration): assign explicit name to custom_object_records linked index#63
mpge merged 2 commits intomasterfrom
fix/custom-object-records-index-name

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented May 6, 2026

Summary

Fixes a mix ecto.migrate failure on PostgreSQL caused by an auto-generated index name exceeding the 63-char identifier limit.

The current line generates escalated_custom_object_records_linked_entity_type_linked_entity_id_index (73 chars). PostgreSQL caps identifiers at 63 chars (NAMEDATALEN-1), so any user with the default escalated_ table prefix hits this on a fresh install.

Same class of bug as escalated-laravel#86 / #87. Solution mirrors the existing convention already used at line 61 of this same migration (name: :unique_field_entity).

Backwards compatibility

Same logic as the Laravel fixes. Each migration runs once and is tracked in schema_migrations:

  1. Migration already succeeded (rare — would only happen on a non-PG adapter or with a custom prefix that kept the auto-name short): the user's schema has the long auto-generated name. Migration won't re-run, so the new explicit name only matters for fresh installs.
  2. Migration failed (default config on PostgreSQL): nothing was created. The fix unblocks them.

No existing install can be broken by this change.

Test plan

  • mix ecto.migrate succeeds on a clean PostgreSQL database with default prefix
  • CI passes

mpge added 2 commits May 5, 2026 21:31
…index

The auto-generated index name `escalated_custom_object_records_linked_entity_type_linked_entity_id_index` is 73 characters — over PostgreSQL's 63-char identifier limit (NAMEDATALEN-1). Phoenix targets PostgreSQL primarily, so this would fail `mix ecto.migrate` for any user installing fresh today.

Use an explicit short name (`custom_object_records_linked_idx`, 32 chars) following the same convention already used at line 61 (`name: :unique_field_entity`).

Backwards compatible: the migration runs only once and is tracked in `schema_migrations`. Anyone for whom it succeeded already has the long auto-generated name; the new short name only applies to fresh installs. Anyone whose migration failed (PostgreSQL with default prefix) is unblocked.
The CI's `mix format --check-formatted` runs against PR-changed files in full. Wrapping the long `create index` line for the previous fix triggered the formatter to also wrap three pre-existing long lines in this file (`add :custom_field_id`, `add :custom_object_id`, `add :business_schedule_id`, and the `unique_index` for `custom_field_values`) — exactly the workflow's intent ("drift cleans up organically as files are touched", per `.github/workflows/lint.yml`).

No semantic change.
@mpge mpge merged commit 6bc23aa into master May 6, 2026
1 check passed
@mpge mpge deleted the fix/custom-object-records-index-name branch May 6, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant