spacedog4
1 week ago
207
14
Laravel

Create a new primary column in production

Posted 1 week ago by spacedog4

Today I have this table where has 3 columns setted as primary, this is causing me so much trouble, how can I create a migration to drop the primary index and create a new increments id column without erasing all data?

I tryied this:

$table->dropPrimary('PRIMARY');
$table->increments('id');

but I got this error Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1 Cannot add a PRIMARY KEY column (SQL: alter table "pedidoproducao" add column "id" integer not null primary key autoincrement)

I need it to be a migration cause our webapp has multiples database, so I need to update all of then

Please sign in or create an account to participate in this conversation.