Fix rename column with long name. #13209

wants to merge 1 commit into


None yet
4 participants

laurocaetano commented Dec 6, 2013

It was raising an error when renaming columns with long names. In order to prevent that, we check if the new_index_name length is greater than the allowed_index_name_length. If exceeds, we truncate it.

Closes #12585

cc @rafaelfranca


egilburg commented Dec 6, 2013

Index length can cause problems in other places as well, e.g. adding an index on multiple columns that exceeds index length. Can there be a reusable solution to this applied to all index operations?


al2o3cr commented Dec 6, 2013

Not a fan of this; at a minimum, this should emit some sort of a warning before truncating names.


laurocaetano commented Dec 6, 2013

Warning the user could be another solution. Lets wait for more feedback and discuss what could be the correct behavior in this case. 😃

@vipulnsward vipulnsward commented on an outdated diff Dec 15, 2013

if generated_index_name ==
- rename_index table_name, generated_index_name, index_name(table_name, column: index.columns)
+ new_index = index_name(table_name, column: index.columns)
+ if new_index.size > allowed_index_name_length
+ new_index = new_index[0..allowed_index_name_length - 1]

vipulnsward Dec 15, 2013


@laurocaetano a problem I see with this is tables with big table names ending up same index names, in exceptional cases, thus landing us back to another problem. Maybe we can check for existing indexes, but that too would be a long stretch.


laurocaetano commented Mar 11, 2014

We found out that this is not going to work, since it's something the user can avoid just using indexes with correct length.
Closing this one.

Thanks guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment