Last active
December 18, 2017 20:37
-
-
Save roalcantara/ee3123c91abe73e5835f3c21ff06f127 to your computer and use it in GitHub Desktop.
PGLoader from Mysql To Public Schema Fixing TimeStamp columns
This file contains hidden or 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
# Load data from mysql to postgres | |
$ pgloader mysql://username:password@localhost/dbname pgsql:///dbname |
This file contains hidden or 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
-- Fix the schema | |
DROP SCHEMA public; | |
ALTER SCHEMA old_schema RENAME TO public; |
This file contains hidden or 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
-- 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