我有一张这样的表格:
...
$table->longText('title')->comment('Event title');
$table->decimal('start_year',13,0)->nullable(true)->comment('Year part of beginning of event date');
$table->decimal('start_month',2,0)->default(0)->comment('Month part of beginning of event date');
$table->decimal('start_day',2,0)->default(0)->comment('Day part of beginning of event date');
...
我需要基于这些列的组合唯一索引。但“标题”是一个长文本。
这个不工作:
$table->unique([['title','255'], 'start_year', 'start_month', 'start_day'],'unique_title_and_date');
迁移工具sais:
[ErrorException]
strtolower() expects parameter 1 to be string, array given
这个也不起作用:
$table->unique(['title(255)', 'start_year', 'start_month', 'start_day'],'unique_title_and_names');
迁移工具sais:
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'title(255)' doesn't exist in table
这个也不起作用:
$table->unique(['title', 'start_year', 'start_month', 'start_day'],'unique_title_and_names');
迁移工具sais:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'title' used in key specification without a key length
如何让迁移工具吃掉这个命令?