Data migration with the nmig tool

Andrey Karazhev
1 min readSep 21, 2021

--

NMIG is an app, intended to make a process of migration from MySQL to PostgreSQL as easy and smooth as possible. It has been written in the TypeScript language and is run on Node.js 10 or higher.

Visit the link for more information: https://github.com/AnatolyUss/NMIG

Installation

Download and install Node.js 10 or higher: https://nodejs.org/en/

Clone and checkout the nmig tool:

git clone https://github.com/AnatolyUss/nmig.git 
cd nmig
git checkout v5.5.0

Configuration

The main configuration script is config.json:

nano config/config.json

If we need to configure a source and target, we can update sections:

"source": {
"host": "localhost",
"port": 3306,
"database": "test_db",
"charset": "utf8mb4",
"supportBigNumbers": true,
"user": "root",
"password": "0123456789"
}
"target": {
"host" : "localhost",
"port" : 5432,
"database" : "test_db",
"charset" : "UTF8",
"user" : "postgres",
"password" : "0123456789"
}

If we need to rename either a table name, column or foreign keys, we should activate an extra config:

"enable_extra_config" : false

The extra configuration script is extra_config.json:

nano config/extra_config.json

To rename names we can update sections:

"tables" : [
{
"name": {
"original": "salary",
"new": "renamed_salary"
},
"columns": [
{
"original": "id",
"new": "renamed_id"
},
{
"original": "employee_id",
"new": "renamed_employee_id"
}
]
},
{
"name": {
"original": "contract",
"new": "renamed_contract"
},
"columns": [
{
"original": "id",
"new": "renamed_id"
}
]
}
]

Usage

Install and run:

npm install 
npm run build
npm start

Enjoy!

Originally published at https://github.com.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response