Skip to content

forcing postgresql column names to lowercase #121

@jschneid-nmdp

Description

@jschneid-nmdp

For my story, the schemas for both the (source) MySQL and (final target) PostgreSQL databases are defined by third-party software.

The two schemas are generally compatible, but the MySQL schema uses uppercase column names, and the final target PostgreSQL schema uses lowercase column names.

Due to other minor PostgreSQL schema discrepancies, I'm first using NMIG to migrate the MySQL data into a NMIG target PostgreSQL database and then using pg_dump --data-only to extract data that can be loaded into the (final target) PostgreSQL database.

The extract-and-load process using pg_dump doesn't work when the NMIG target PostgreSQL database has uppercase column names (because the final target PostgreSQL database has lowercase column names).

To get past this problem, I made a one-line change to ExtraConfigProcessor.ts, modifying the getColumnName function to force all column names in the NMIG target PostgreSQL database to lowercase.

diff --git a/src/ExtraConfigProcessor.ts b/src/ExtraConfigProcessor.ts
index da5fa74..0d8fc22 100644
--- a/src/ExtraConfigProcessor.ts
+++ b/src/ExtraConfigProcessor.ts
@@ -87,7 +87,7 @@ export const getColumnName = (
         }
     }
 
-    return retVal;
+    return retVal.toLowerCase();
 };
 
 /**

This hack was enough to solve my problem. Not sure if this story is unusual, or whether it might make sense to think about adding a general NMIG configuration setting to force lowercase column names in the target db.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions