Migration Utility

Flexter migration tool that comes with the flexchma module and can be used to move schemas between environments.

1. Installation

pip install -r /usr/share/flexter/flexchma/schema_migration/requirements.txt

2. Usage

The following command can be used to get all the supported parameters:

$ /usr/share/flexter/flexchma/schema_migration/migration.py -h

or

$ ~/.local/share/flexter/flexchma/schema_migration/migration.py -h

usage: migration.py [-h] [-x 1] [-O /path/to/output] [-i /path/to/directory]
                    [-H localhost] [-P 5432] [-U flex2er] [-p *****] [-D x2er]
                    [--disable-stats] [--disable-logical] [-l LOG_PATH]
                    [--export-full]

Flexter schema migration tool

Export section:
  -x 1, --export-schema 1
                        Use to export schema, requires id_sch to export
  -O /path/to/output, --schema-output /path/to/output
                        Path to export output

Import section:
  -i /path/to/directory, --import-schema /path/to/directory
                        Use to import schema, requires path to exported schema directory

Connection details:
  -H localhost, --host localhost
                        Flexmeta Postgresql hostname
  -P 5432, --port 5432  Flexmeta Postgresql port
  -U flex2er, --user flex2er
                        Flexmeta Postgresql username
  -p *****, --password *****
                        Flexmeta Postgresql password
  -D x2er, --database x2er
                        Flexmeta Postgresql database

Optional parameters:
  --disable-stats       Disable stats exporting/importing
  --disable-logical     Disable logical schema exporting/importing
  -l LOG_PATH, --log-path LOG_PATH
                        Path where to write stdout/stderr
  --export-full         Export the given schema and all its parent schemas without consolidating them

2.1 Export schema

To export a schema from the flexter metaDB, run one of the following commands:

Default python

./migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --export-schema id_sch

Python 2

python2 migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --export-schema id_sch

Python 3

python3 migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --export-schema id_sch

The output will then be saved under the local output directory

$ ls output
data_unit.tsv  du_def.tsv  du_stat.tsv  job.tsv  lschma.tsv  map.tsv  rcol.tsv  rtab_fk.tsv  rtab.tsv  schma.tsv  ...

You can also specify an output directory path using the -O <path> argument

./migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --export-schema <id_sch> -O /tmp/output

2.2 Import schema

To import the schema you need to provide the path to the schema files exported in a previous step.

Default python

./migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --import-schema output/

Python 2

python2 migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --import-schema output/

Python 3

python3 migration.py -H localhost -P 5432 -U flex2er -p <password> -D x2er --import-schema output/