Skip to content

Instantly share code, notes, and snippets.

@lopezjurip
Created March 29, 2021 14:11
Show Gist options
  • Save lopezjurip/cd92f879bc92af698f85ad0433a953cd to your computer and use it in GitHub Desktop.
Save lopezjurip/cd92f879bc92af698f85ad0433a953cd to your computer and use it in GitHub Desktop.
Migrate Postgres string field to integer if present else null
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