Using pg_chameleon

One way to move from MySQL/MariaDB to PostgreSQL is to use Federico Campoli's tool, called pg_chameleon, which can be downloaded for free from GitHub (https://github.com/the4thdoctor/pg_chameleon). It has been explicitly designed to replicate data to PostgreSQL and does a lot of work, such as converting the schema for us.

Basically, the tool performs the following four steps:

  1. pg_chameleon reads the schema and data from MySQL and creates a schema in PostgreSQL.
  2. It stores MySQL's master connection information in PostgreSQL.
  3. It creates primary keys and indices in PostgreSQL.
  4. It replicates from MySQL/MariaDB to PostgreSQL.

The pg_chameleon tool provides basic support for DDLs such as CREATE, DROP, ALTER TABLE, and DROP PRIMARY KEY. However, due to the nature of MySQL/MariaDB, it does not support all DDLs. Instead, it covers the most important features.

However, there is more to pg_chameleon. I have stated extensively already that data is not always the way it should be or is expected to be. The way pg_chameleon approaches the problem is to discard rubbish data and store it in a table called sch_chameleon.t_discarded_rows. Of course, this is not a perfect solution but, given the fairly low-quality input, it is the only sensible solution that comes to my mind. The idea is to let developers decide what to do with all the broken rows. There is really no way for pg_chameleon to decide on how to handle something that has been broken by somebody else.

Recently, a lot of development has taken place and a lot of work has gone into the tool. Therefore, it is really recommended to check out the GitHub page and read through all the documentation. Features and bug fixes are being added as we speak. Given the limited scope of this chapter, full coverage is not possible here.

Stored procedures, triggers, and more need special treatment and can only be handled manually. The pg_chameleon tool cannot process these things automatically.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset