Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active December 18, 2017 20:37
Show Gist options
  • Save roalcantara/ee3123c91abe73e5835f3c21ff06f127 to your computer and use it in GitHub Desktop.
Save roalcantara/ee3123c91abe73e5835f3c21ff06f127 to your computer and use it in GitHub Desktop.
PGLoader from Mysql To Public Schema Fixing TimeStamp columns
# Load data from mysql to postgres
$ pgloader mysql://username:password@localhost/dbname pgsql:///dbname
-- Fix the schema
DROP SCHEMA public;
ALTER SCHEMA old_schema RENAME TO public;
-- Run the output to fix timeStamp columns
SELECT CONCAT('ALTER TABLE ', table_name, ' ALTER ', column_name ,' SET DATA TYPE timestamp(0) without time zone;')
FROM information_schema.columns
WHERE TABLE_SCHEMA='public'
AND TABLE_CATALOG='old_schema'
AND DATA_TYPE like 'timestamp%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment