My old migration is:
Schema::create('item_tag', function (Blueprint $table) {
$table->integer('item_id')->unsigned()->index();
$table->foreign('item_id')->references('id')->on('items')->onDelete('cascade');
$table->integer('tag_id')->unsigned()->index();
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
$table->primary(['item_id', 'tag_id']);
});
Now I want add new auto increment column to this and drop old primary key
I try this:
Schema::table('item_tag', function (Blueprint $table) {
$table->unsignedInteger('id', true)->first();
$table->dropPrimary();
$table->primary('id');
});
But it have a error after migrate:
SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined