logo_red_slogan

Migrating data from Microsoft SQL server to Postgres can be done with a program called PG loader. This swiss army knife can import data from several different backends including MySQL on the fly and is relatievely easy to use.

First off, you need to install it. if you want to run it on your Linux or Mac PC, the docker container may be the best solution. But it’s included in the Postgres apt repositories.

After installing PG loader, you need to create a load file that containst the instructions on how to run the migration like this:

load database
     from mssql://<user>:<password>@<SQL hostname>:6789/<database>
     into postgresql://<user>:<password>@<PG hostname>/<PG database>

WITH create tables
alter schema 'dbo' rename to 'public';

Run the migration with:

pgloader -v <loadfile>

If this throws an error on a missing fuction for uid fields, you need to run this on the Postgres database first:

sudo -u postgres psql
postgres=# \c <yourdatabase>
create extension "uuid-ossp";

Happy migration.