In laravel 9 app running migration with statement(mysql database) :
$table->foreignId('notification_config_id')
->nullable()
->references('id')
->on('notification_configs')
->onUpdate('RESTRICT')
->onDelete('RESTRICT');
I got error :
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'notification_configs_notification_types_notification_config_id_foreign' is too long (SQL: alter table
notification_configs_notification_types
add constraintnotification_configs_notification_types_notification_config_id_foreign
foreign key (notification_config_id
) referencesnotification_configs
(id
) on delete RESTRICT on update RESTRICT)
looks like name of the index is set automatically, can I set it manually ? I tried :
$table->foreignId('notification_config_id')
->nullable()->references('id')
->on('notification_configs')
->onUpdate('RESTRICT')
->onDelete('RESTRICT')
->name('notification_configs_longname_ref');
But the same error anyway... How that can be fixed?
Thanks!