Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
;
like image 213
medley56 Avatar asked Sep 15 '25 13:09

medley56


1 Answers

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

like image 102
Dimitri Fontaine Avatar answered Sep 17 '25 03:09

Dimitri Fontaine