Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forcing postgresql column names to lowercase #121

Open
jschneid-nmdp opened this issue Nov 17, 2023 · 2 comments
Open

forcing postgresql column names to lowercase #121

jschneid-nmdp opened this issue Nov 17, 2023 · 2 comments

Comments

@jschneid-nmdp
Copy link

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.

@jonfreeland
Copy link

Did you see #106? That seems to do what you're looking for, albeit undocumented.

@jschneid-nmdp
Copy link
Author

Interesting. I remember making a half-hearted attempt to use that, but I eventually found it easier to hack the code and not use extraConfig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants