Created
December 3, 2012 12:51
-
-
Save gjergjsheldija/4194848 to your computer and use it in GitHub Desktop.
postgres change column from boolean to inetger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE table_name ALTER column_name SET DEFAULT null; | |
ALTER TABLE table_name | |
ALTER column_name TYPE INTEGER | |
USING | |
CASE | |
WHEN false THEN 0 | |
ELSE 1 | |
END; | |
ALTER TABLE table_name ALTER column_name SET DEFAULT 0; | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs to be:
CASE column_name WHEN false THEN 0 ELSE 1 END;