Skip to content

Instantly share code, notes, and snippets.

@yurikoval
Created November 25, 2014 11:33
Show Gist options
  • Select an option

  • Save yurikoval/0abde914286600626b32 to your computer and use it in GitHub Desktop.

Select an option

Save yurikoval/0abde914286600626b32 to your computer and use it in GitHub Desktop.
Update column to boolean in Postgres after MySQL migration
ALTER TABLE my_table ALTER COLUMN my_column DROP DEFAULT;
ALTER TABLE my_table ALTER my_column TYPE bool USING CASE WHEN my_column=0 THEN FALSE ELSE TRUE END;
ALTER TABLE my_table ALTER COLUMN my_column SET DEFAULT FALSE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment