Shorter default index names for references

Whenever I try to create an index (e.g. by using add_reference in a migration, if the table name is too long, I get the following error:

Index name 'extremely_long_index_name_which_is_more_than_sixty_three_characters
' on table 'table_name' is too long; the limit is 63 characters

This happens on PostgreSQL, since the index name limit is 63 characters (hard coded and cannot be changed)

Which leads me to always add the option index: { name: 'shorter_index_name' } to any long reference, in order to prevent the issue.

Would it be possible to change this default behaviour to always create names of constant length? This would be similar to how foreign keys are always of the format fk_rails_83838.

2 Likes