Migration from previous version

Migration description:

At the moment, migration available only for PostgreSQL database.

Migration makes next changes in database structure:

  • Persons will be replaced by faces. For each person’s face, it creates each face with the same face_id and old person_id or external_id as new face’s external_id (see PERSON_EXTERNAL_ID_SOURCE in config). For each new face user_data will be copied from a person. As avatar for face, it creates a link to its sample.

  • All links between persons without faces and lists will be converted to links between new faces and lists.

Additionally, if it needs to aggregate persons’ descriptors, migration makes the next changes:

  • For each person with more than one linked faces, it creates new aggregated descriptor, faces with id the same as old person_id, old descriptors will not migrate not the new database.

How to migrate database from luna v3 to v4:

  1. Prepare config file base_scripts/migration_3_to_4/config/config.conf, including:

    • AGGREGATE_PERSON_FACE - if 1 aggregate person’ faces’ descriptors and create new faces with face_ids with old person_ids, if 0 - do not

    • AGGREGATE_CONCURRENCY - if AGGREGATE_PERSON_FACE set to 1, this parameter set concurrency for requests (get descriptors) to v3 luna-broker

    • DESCRIPTOR_VERSION - descriptor version in v3 database, 46 for default

    • PERSON_EXTERNAL_ID_SOURCE - what id to store as new face’s external_id. Possible values:
      • person_id

      • external_id

      Warning: another field’s data will not exist in the new database

    • BROKER_REQUESTS_CONCURRENCY - concurrency for get descriptors requests to luna-broker (v.3), 100 for default

  2. Execute script for prepare migration:

    python3 prepare_migrations.py
    
  3. First migration stage (migrate face, person, list, list_face, attribute tables) using copy command:

    bash migrate_1.sh
    
  4. Second migration stage (migrate descriptors) using python script:

    python migrate_2.py
    

    If there are any errors, it will be stored in base_scripts/migration_3_to_4/error.log file, also will be present text log files(base_scripts/migration_3_to_4/Migration v3->v4: descriptors_INFO.txt, base_scripts/migration_3_to_4/Migration v3->v4: descriptors_ERROR.txt).

After migration complete every user needs to know his account_id to use LUNA-API, it can be received from the old luna-API database.