I have already checked the other topics but no solution worked with me. I tried the last time:
public function up()
{
if(Schema::hasColumn('orders_products_variations','id')) {
Schema::table('orders_products_variations',function (Blueprint $table) {
$table->unsignedInteger('id')->change();
$table->dropPrimary();
$table->dropColumn('id');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('clients', function (Blueprint $table) {
$table->string('id');
});
}
And the error message is :
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: alter table
orders_products_variations
drop primary key)
Any idea?
id
is defined as auto increment, so it must be the primary key. You should be able to just drop the id column without any of the other hoops. – aynberSchema::table
calls. The first will drop the primary key, while the second drops the entire column. – PtrTon