You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting this error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'snow_lesson_category_snow_mo nitor_snow_lesson_category_id_foreign' is too long
With this migration (or with any migration with long table names): php artisan make:migration:pivot snow_monitors snow_lesson_categories
Can be solved by providing your own shorter key name.
In Laravel 11, I fixed it by adding the attribute indexName: in the ->constrained() method. On the other hand, the ->index() method is ignored. For example:
$table->foreignIdFor(\App\Models\User::class,'created_id')->nullable()->comment('user id who has created the record')
->constrained(\App\Models\User::make()->getTable(),indexName: 'custom_c_user_fk')->onUpdate('cascade')->onDelete('cascade');
Getting this error:
[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'snow_lesson_category_snow_mo nitor_snow_lesson_category_id_foreign' is too long
With this migration (or with any migration with long table names):
php artisan make:migration:pivot snow_monitors snow_lesson_categories
Can be solved by providing your own shorter key name.
This also happened with my primary key.
The text was updated successfully, but these errors were encountered: