入力します。laravel移行 - 列のユニークな組み合わせは、私はこのようなcolumsを持つテーブルを持っているLONGTEXT
...
$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');
...
私は、これらの列に基づいて合成一意のインデックスが必要です。しかし、 'title'はlongTextです。
この1が動作していない:
$table->unique([['title','255'], 'start_year', 'start_month', 'start_day'],'unique_title_and_date');
移行ツールのサイスを:
[ErrorException]
strtolower() expects parameter 1 to be string, array given
この1も動作していない:
$table->unique(['title(255)', 'start_year', 'start_month', 'start_day'],'unique_title_and_names');
移行ツールのサイス:
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'title(255)' doesn't exist in table
この1つはまた、動作していない:
$table->unique(['title', 'start_year', 'start_month', 'start_day'],'unique_title_and_names');
移行ツールのサイス:移行ツールは、このコマンドを食べるようにする方法
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'title' used in key specification without a key length
を?
'title'は実際には歴史的理由のために説明のような列です。だから、本当に長いテキストを含むことができなければなりません。 –