Skip to content

Migrate ticketing data to CoreAPI

The migration scripts copy everything the old ticketing backend (ticketing, ticket-admin, ticket-cms) holds into the new stack (coreapi, authapi-stg and the new admin spatio): the database, the payment and email settings, and the uploaded files. Run them before the route cutover, and once more right before it to catch up.

Before you start

  • Shell access to ticket-node-1. Run every script there, in ~/schema-dump.
  • The scripts read passwords and keys at run time. Never put them in chat, files or git.
  • Never commit ticket-iac/migration/.

If a script says no such file, you are in the wrong folder. If it says permission denied, run chmod +x <SCRIPT>.

Scripts

Every script has a dry mode that prints its plan and changes nothing. Always run dry first and read the plan.

Goal Command Notes
Plan everything ./run-all.sh dry Changes nothing
Apply everything ./run-all.sh apply Asks you to type apply
Catch up before cutover RESET=1 ./run-all.sh dry, then RESET=1 ./run-all.sh apply Wipes CoreAPI's ticketing data and reloads it from the old system. Only safe before cutover
Data only ./migrate-johorzoo.sh dry\|apply\|verify Stops if the target already has data, unless CLEAN=1
Payment and email settings only python3 migrate-pos-profiles.py dry\|apply\|verify\|check Creates only what is missing; REFRESH=1 overwrites and WIPE=1 deletes existing profiles first: run dry with the same flag first
Files only ./migrate-storage.sh dry\|apply\|verify Adds files only; MIRROR=1 also deletes files in CoreAPI's volume that the old volume doesn't have: run dry with the same flag first

What each part does:

  • Data: copies the database johorZoo.johorzoo into coreapi.johorzoo (24 tables) in one transaction, then compares row counts. verify repeats the comparison.
  • Payment and email settings (profiles): builds the Zoo POS, JohorPay and eTiket Gmail settings from the old general table, encrypts them the way CoreAPI does, and links them to ticket groups. check calls CoreAPI's public ticket list and bank list: HTTP 200 with real data proves the settings decrypt and the remote services answer.
  • Files: copies the uploaded files from the old volume to CoreAPI's volume and compares paths and sizes. The last run matched 1550 of 1550 files.

Rules

  • COREAPI_SECRETS_ENCRYPTION_KEY must never change once profiles exist: the stored settings can't be decrypted with a new key.
  • Ticket groups: 1 = Taman Botani, 2 = Zoo Johor, 5 = KSM.
  • Never run RESET=1 after CoreAPI has real orders: it would delete them.

Run the migration

  1. Plan:

    cd ~/schema-dump && ./run-all.sh dry
    

    Expected: a plan for data, profiles and files, and no changes. 2. Apply, typing apply when asked:

    ./run-all.sh apply
    
  2. Verify each part:

    ./migrate-johorzoo.sh verify
    python3 migrate-pos-profiles.py check
    ./migrate-storage.sh verify
    

    Expected: row counts match for all 24 tables, check returns HTTP 200 with real ticket and bank data, and every file path and size matches.

Check parity with the old system

CoreAPI only has to behave like the old ticketapi: a call that fails on both is acceptable. Send the same calls to both and note the differences.

Ticket group Result (2026-11-24)
Zoo Johor (2) Matches
Taman Botani (1) Empty on both
KSM (5) Fails on both. The bank list differs only for this group

Open settings (2026-11-24)

  • KSM (group 5) has no POS or payment profile yet. The KSM server didn't answer from the cluster. Test it from the node and from the old ticketing pod first (a network or whitelist fix), then add the profile to migrate-pos-profiles.py.
  • Email usage mappings: run python3 migrate-pos-profiles.py dry, read the plan, then apply. It maps all five email kinds to the single eTiket Gmail profile, as the old system does.
  • Taman Botani: the ticket list was empty on one date. Try another date and compare with the old system.

Before cutover, each of these is either filled in or explicitly accepted as is.