vendredi 31 juillet 2015

Convert mysql to postgres and retain default value

I have a MySQL database that I wish to convert into Postgres. One issue I encountered is to convert tinyint(1) (synonym to boolean) columns into "true" boolean and retain the default value of the MySQL column which can be either 0 or 1 but in Postgres the respective values are true or false. The SQL I'm trying:

ALTER TABLE "payments" ALTER COLUMN "is_automatic" TYPE boolean USING CAST("is_automatic" as boolean);

The error message:

ERROR:  default for column "is_automatic" cannot be cast automatically to type boolean

I would think it would be possible to cast this value somehow. Is this possible to do or do I have to manually add this to the migration script?

Aucun commentaire:

Enregistrer un commentaire