Skip to content

Conversation

@fkmy
Copy link

@fkmy fkmy commented Nov 12, 2024

Thank you for this useful tool!

Since MySQL 8.0, the following error occurred when the table name is long.
ERROR 1059 (42000) at line 115: Identifier name 'too_long_table_name_ibfk_1' is too long

Ref: https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html

To avoid this error, if the table name is long, the response is to specify the FK name.

Since MySQL 8.0, the following error occurred when the table name is long.
ERROR 1059 (42000) at line 115: Identifier name 'too_long_table_name_ibfk_1' is too long

Ref: https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html
// If the table name is too long, the foreign key name will also be too long,
// and an error will occur if the foreign key name exceeds 64 characters.
// I think 4 digits is enough for numbering.
if len(c.Table) >= 56 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64 characters - ( "_ibfk_"(6 characters) + number(1 or more characters) )
= 57 characters

Table name is allowed up to 57 characters, but considering the case where number is 2-digit, set it to 56 characters.

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