Converting H-Sphere System Database From MS SQL to PgSQL


PgSQL is the only supported format for the H-Sphere system database. The conversion procedure suggested in this document takes two steps:


Convert database from MSSQL Server to MySQL

  1. Rename the following fields:
    table esc_rules: rename interval to interval2
    table revenue: rename usage to usage2
    This must be done to avoid conflicts in MySQL, and must be changed back in the MySQL dump.
  2. Start mssql2mysql.exe and configure setting for MSSQL/MySQL servers (hosts, usernames, passwords, new database name for mysql) and save settings.
  3. Click Connect to connect to mssql database and select the database to convert
  4. Select all necessary tables or press Select All to select all tables
  5. Click Start to start database conversion
  6. To see the database after the conversion:
    mysql hsphere_mysql (for example)


Convert database from MySQL Server to PgSQL

Execute all suggested queries in one transaction. Replace PG_HOST_NAME with the name of the host where PgSQL server is running, like

  1. Dump tables and data from mysql:
    mysqldump.exe hsphere_mysql > hsphere_dump
  2. As the result, you will get a MySQL dump with table structure and data (hsphere_dump)
  3. In MySQL dump, rename the following fields:
    table esc_rules: rename interval2 to interval
    table revenue: rename usage2 to usage
  4. Convert mysql dump to pgsql dump: hsphere_dump > hsphere_pgsql

    As the result, you will get a converted dump (hsphere_pgsql)
  6. If the database already exists, delete it:
    dropdb -h PG_HOST_NAME -U wwwuser hsphere_pgsql
  7. Create a new (empty) database:
    createdb -h PG_HOST_NAME -U wwwuser hsphere_pgsql
  8. Restore the database from dump (tables and data):
    psql -h PG_HOST_NAME -d hsphere_pgsql -U wwwuser -f hsphere_pgsql > migrate_errors

    -d - database name
    -f - file with dump
    As a result, you will see convertion results in the migrate_errors file.
  9. Connect to the database and check all tables and data:
    psql -h PG_HOST_NAME -d hsphere_pgsql -U wwwuser
  10. For each record of the sequences table, run the following two commands against the Postgres DB:
    CREATE SEQUENCE "<seq_name>" start <id>;
    SELECT nextval ('<seq_name>');
    For example, for the record newid -> 276488, execute the following SQL statements:
    CREATE SEQUENCE "newid" start 276488;
    SELECT nextval ('newid');

Home   Products   Services   News
© Copyright. . PSOFT. All Rights Reserved. Terms | Site Map