Created
March 29, 2021 14:11
-
-
Save lopezjurip/cd92f879bc92af698f85ad0433a953cd to your computer and use it in GitHub Desktop.
Migrate Postgres string field to integer if present else null
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 "public"."usage_stats" | |
ALTER COLUMN "resSize" TYPE INT USING CASE WHEN "resSize" ~ '^[-+0-9]+$' THEN "resSize"::integer ELSE NULL END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment