dolthub / pg2mysql

Script to convert Postgres dump files to MySQL dump files
Apache License 2.0
38 stars 10 forks source link

Add option to change schema name #39

Open alfredosilvestre-natixis opened 1 year ago

alfredosilvestre-natixis commented 1 year ago

Since in Postgres a database contains one or more named schemas and in MySQL schema=database, when converting from Postgres, add an option to set the database name for MySQL.

In our case, we have a database named "testdb" and the schema named "public", but in MySQL we only have the schema "testdb", however in the converted file it will keep the Postgres schema name.

Right now we are using sed to replace:

sed -i -e 's/\s${POSTGRES_SCHEMA};/ ${MYSQL_DB};/gi' "${MYSQL_DUMP}.sql"
sed -i -e 's/\s${POSTGRES_SCHEMA}\./ ${MYSQL_DB}\./gi' "${MYSQL_DUMP}.sql"