In database migration in Laravel 6, SQLState[42000]: Syntax Error or Access Violation: 1059 Identifier nametheme_installation_version_preset_theme_store_theme_version_id_indexis too long
1. When performing database migration, an error is reported: sqlstate[42000]: Syntax Error or Access Violation: 1059 Identifier nametheme_installation_version_preset_theme_store_theme_version_id_indexis too long. as shown in Figure 1
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'theme_installation_version_preset_theme_store_theme_version_id_index' is too long (SQL: alter table `theme_installation_version_preset` add index `theme_installation_version_preset_theme_store_theme_version_id_index`(`theme_store_theme_version_id`))
The index length limit of MySQL 5.7 defaults to 64, while the length of the Theme_Installation_Version_Preset_Theme_Store_Theme_Version_ID_Index is 68. as shown in Figure 2
3. In Laravel 6, each indexing method accepts an optional second parameter to specify the name of the index. If omitted, the name will be generated based on the name of the table and column. The final decision explicitly specifies the name of the index: TIVP_THEME_STORE_THEME_VERSION_ID_INDEX. Table names use only the first letter.
$table->unsignedBigInteger('theme_store_theme_version_id')->comment('主题商店的主题版本ID')->index();
$table->unsignedBigInteger('theme_store_theme_version_id')->comment('主题商店的主题版本ID')->index('tivp_theme_store_theme_version_id_index');
4. The migration is successful.
![在执行数据库迁移时,报错:SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'theme_installation_version_preset_theme_store_theme_version_id_index' is too long](https://www.shuijingwanwq.com/wp-content/uploads/2022/06/1-3.png)
