When create foreign keys there is set pattern in Forge class how the key name will be generated. This ends up making problem for tables and fields with long names, below [mysqli_sql_exception] is thrown.
Specified key was too long; max key length is 767 bytes
Solution would be to add an options array at end in which constraint name can be defined and in code the update can be done if constraint name is defined then skip auto generation part for key name. below is where this change is recommended
Add options array at end of this function which excepts constraint name
When create foreign keys there is set pattern in Forge class how the key name will be generated. This ends up making problem for tables and fields with long names, below
[mysqli_sql_exception]
is thrown.Specified key was too long; max key length is 767 bytes
Solution would be to add an options array at end in which constraint name can be defined and in code the update can be done if constraint name is defined then skip auto generation part for key name. below is where this change is recommended
Add options array at end of this function which excepts constraint name
https://github.com/codeigniter4/CodeIgniter4/blob/920488950b62ca394c3c7183a91409759deef61b/system/Database/Forge.php#L404
Skip default key name and used the constraint name passed in options array to addForeignKey method
https://github.com/codeigniter4/CodeIgniter4/blob/920488950b62ca394c3c7183a91409759deef61b/system/Database/Forge.php#L1057