3

I try to rename a column in a migration:

\Schema::table('invitations', function (Blueprint $table) {
    $table->renameColumn('service_id', 'project_id');
});

Running this result in an error:

Unknown database type jsonb requested, Doctrine\DBAL\Platforms\PostgreSQL92Platform may not support it.

My table as a jsonb column, I think it's the problem but I don't know why this problem occurs (because service_id is not a jsonb column).

How can I rename my column? (and why does it not work with what I wrote?)

rap-2-h
  • 30,204
  • 37
  • 167
  • 263

2 Answers2

5

I wrote similar migration for MySQL, IMHO, no difference with Psql. The function renameColumn() works only with Doctrine\DBAL` and I didn't wanted to add this dependency to our project. So I did it like that

DB::transaction( function () {
    DB::raw('ALTER TABLE invitations RENAME COLUMN service_id TO project_id');
});

Sorry for my English.

maches
  • 398
  • 1
  • 11
1

If you have installed the doctrine/dbal package and have column names in camleCase format, you can try

Schema::table('invitations', static function (Blueprint $table) {
    $table->renameColumn('"serviceId"', '"projectId"');
});
Maxim Paladi
  • 91
  • 1
  • 7