小编min*_*ras的帖子

Laravel 4迁移Schema - 索引长度

我遇到了laravel迁移的问题,我需要为特定列设置索引长度,但看起来Schema/Blueprint index()没有这样的功能.Laravel文件

      [Illuminate\Database\QueryException]                                         
      SQLSTATE[42000]: Syntax error or access violation: 
      1170 BLOB/TEXT column 'description' used in key specification 
      without a key length (SQL: alter table `Customers` 
      add index `description_idx`(`description`)) 
Run Code Online (Sandbox Code Playgroud)

原始的sql查询行:

KEY `description_idx` (`description`(100)) // index length = 100
Run Code Online (Sandbox Code Playgroud)

Laravel迁移代码行:

$table->text('description')->nullable()->index('`description_idx`'); // no index length here
Run Code Online (Sandbox Code Playgroud)

我觉得我能做的最好的事情就是改变列类型,但也许有更合适的方法来解决这个问题?

laravel laravel-4

7
推荐指数
1
解决办法
1768
查看次数

标签 统计

laravel ×1

laravel-4 ×1