unique constraint Error
If I add any unique constraint then
General error: 1503 A UNIQUE INDEX must include all columns in the table's partitioning function
I got this error.
Here is my migration
Schema::create('cp_transactions', function (Blueprint $table) {
$table->bigInteger('id');
$table->primary(['id','date']);
$table->string('trx_id')->index('trx_id')->unique();
$table->date('date')->index('date')->nullable();
$table->timestamps();
});
Schema::forceAutoIncrement('cp_transactions', 'id');
Schema::partitionByYearsAndMonths('cp_transactions', 'date', 2019);
Can you please help me to resolve this issue?
Same error
getting same error by implementing unique check on any db column
Same error
@sts-ryan-holton, @workOfDsYasir
Yes, there is a constraint by MySQL end. If you are going to apply a database partition then you are unable to add the unique index.
How did you resolve it? It seems the docs: $table->primary(['id','date']); doesn't work
How did you resolve it? It seems the docs:
$table->primary(['id','date']);doesn't work
You have to create composite key rather than primary key
and to create composite key $table->primary(['id','date']); this is the way.
This isn't working lol/