Giter Site home page Giter Site logo

hexaaproject / hexaa-migrator Goto Github PK

View Code? Open in Web Editor NEW
0.0 6.0 0.0 18 KB

HEXAA database migrator to HEXAA version 2.

License: Apache License 2.0

Dockerfile 2.14% Python 87.91% Shell 9.95%
datab database-migration python hexaa docker sql sql-migration

hexaa-migrator's Introduction

HEXAA migrator

Table of Contents

Usage

The scripts moves data from one MySQL/Maria DB to another.

Creating databases

If you want to migrate from an SQL dump, import it into a DB first:

CREATE DATABASE hexaa_dump;
GRANT ALL PRIVILEGES ON `hexaa_dump`.* TO 'hexaa'@'%'
mysql --host 127.0.0.1 -u hexaa -p$MYSQL_PASSWORD hexaa_dump < hexaadump_2019-03-04.sql

You need to prepare the schema in the target DB. You can achieve this by running php app/console doctrine:schema:create in the new (version 2) HEXAA, or manually running the schema creation script in this repo:

mysql --host 127.0.0.1 -u hexaa -p$MYSQL_PASSWORD hexaa < hexaa_schema_new.sql

Dependencies

To install dependencies, run this command:

pip3 install -r requirements.txt

Arguments

You need to specify the source and target DB connection params:

  --old-host OLD_HOST, -oh OLD_HOST
                        Address of old DB (default: 127.0.0.1).
  --old-port OLD_PORT, -opo OLD_PORT
                        Port old DB (default: 3306)
  --old-user OLD_USER, -ou OLD_USER
                        User for old DB.
  --old-passwd OLD_PASSWD, -opw OLD_PASSWD
                        Password for old DB.
  --old-db OLD_DB, -od OLD_DB
                        Database name for old DB.

  --new-host NEW_HOST, -nh NEW_HOST
                        Address of new DB. (default: 127.0.0.1).
  --new-port NEW_PORT, -npo NEW_PORT
                        Port new DB (default: 3306).
  --new-user NEW_USER, -nu NEW_USER
                        User for new DB.
  --new-passwd NEW_PASSWD, -npw NEW_PASSWD
                        Password for new DB.
  --new-db NEW_DB, -nd NEW_DB
                        Database name for new DB.

If you want to change the prefix of entitlement URI's:

  --old-prefix OLD_PREFIX
                        Old entitlement URI prefix to be replaced.
  --new-prefix NEW_PREFIX
                        New entitlement URI prefix.

Example:

./migrator.py \
    -ou hexaa -opw hexaa -od hexaa_dump \
    -nu hexaa -npw hexaa -nd hexaa \
    --old-prefix 'urn:geant:niif.hu:hexaa' \
    --new-prefix 'urn:geant:hexaa.eu:hexaa'

Docker

For easier usage with the Ansible+Docker based HEXAA installation:

docker build -t migrator .

docker stop hexaa-backend hexaa-frontend-web
docker run \
    -it --rm \
    --network hexaa_backend \
    -v /path/to/hexaadump_xy.sql:/hexaadump.sql \
    migrator
docker start hexaa-backend hexaa-frontend-web

Details

Entitlement URI update

If you specify it in the CLI arguments, the script will update the URI prefix of entitlements. URI's that don't start with the old prefix will be copied unchanged.

Link transformation

Old schema:

@startuml

Organization -- EntitlementPack
EntitlementPack --> Service

(Organization, EntitlementPack) .. organization_entitlement_pack

class organization_entitlement_pack {
    status
}

@enduml

New schema:

@startuml

Link --> Organization
Link --> Service

Link -- EntitlementPack
EntitlementPack --> Service

(Link, EntitlementPack) .. link_entitlement_pack

class Link {
    status
}

@enduml

Note: The (organization_id,service_id) foreign key pair is a unique key in the Link table

hexaa-migrator's People

Contributors

szabogyula avatar toth-dev avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.