Prepare database dump using mysqldump
:
mysqldump -u [username] -p [databaseName] --compatible=postgresql --default-character-set=utf8 > database.sql
Clone mysql-postgresql-converter
project:
git clone [email protected]:lanyrd/mysql-postgresql-converter.git
cd mysql-postgresql-converter
Assuming that your mysql/mariadb dump is named database.sql,
place that file into the mysql-postgresql-converter
directory.
Convert mysql dump to postgresql dump:
python db_converter.py database.mysql database.psql
Replace datetime
field with timestamp
field.
sed -i 's/datetime(6)/timestamp with time zone/' database.psql
Import dump into postgres:
psql -U dbname -f database.pgsql
@sajid-nltsf:
It used to work back then. Raise an issue in the lanyrd/mysql-postgresql-converter.