Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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