mysqlpostgresqlpgloader

Can pgloader exclude specific columns in a MySQL table?


I am using a loading file with pgloader and there is a particularly problematic table in my MySQL database with malformed datetimes. I want to just skip that column during the migration. How can I do this in a loading file? Something like:

LOAD DATABASE 
    FROM mysql://root@localhost/mydb 
    INTO postgresql:///mypgdb
    INCLUDING ONLY TABLE NAMES MATCHING 
    'Table_with_Datetimes_Column' AS dt,
    'My_Other_Table'
    EXCLUDING dt.Malformed_Column
;

Solution

  • You can exclude the problematic table entirely, and then migrate over data from a view, using the MATERIALIZING VIEW clause of the load command. So first define a view on-top of your table wherein you omit the problematic column, then

    exclude table name matching 'Table_with_Datetimes_Column'
    materialize views 'v_Table_without_Datetimes_Column'
    

    See the examples in the test directory in the repository for pgloader, in particular the sakila.load one: https://github.com/dimitri/pgloader/blob/master/test/sakila.load