Ki Ko
Ki Ko

Reputation: 322

Laravel migration - Update id field from integer auto increment to string

I tried to change id field from Integer auto increment to string but after I run migrate, the structure of MYSQL's not change.

This is my code:

Schema::table('table', function ($table) {
    $table->dropPrimary();
    $table->string('id', 50)->change()->primary();
});

Please help me, thank you so much.

Upvotes: 1

Views: 1201

Answers (1)

Jahid Mahmud
Jahid Mahmud

Reputation: 1136

You should write this. Hopefully this will solve your problem

Schema::table('table', function ($table) {
    $table->dropPrimary('id');
    $table->string('id', 50)->change()->primary();
});

Also you should check if doctrine/dbal is installed successfully

Upvotes: 2

Related Questions