Switching from MySQL to PostgreSql - unique error

The current app runs on MySQL and thinking about switching to PostgreSQL.

On running migration scripts, it dies at statement to to alter a column to unique.

Code in migration script:
$this->alterColumn({{%table}}, ‘id’, $this->string(50)->unique());

The sql causing error:
ALTER TABLE “table” ALTER COLUMN “id” TYPE varchar(50) UNIQUE’

The syntax in psql should be in format:
ALTER TABLE the_table ADD CONSTRAINT constraint_name UNIQUE (thecolumn);

Is this a bug or is there a way to fix so that the same code can run on both mysql and pgsql?

I’ve just yesterday discovered this bug as well. There is issue already reported related to this but did not get any love yet. I’ll try to work on this but I can not promise anything.