Appearance
The migration tool
genera-migrate moves an organisation's existing cases and their files in before it goes live, from another case management system's export, a spreadsheet, or folders on a network drive. For up to 500 cases of one type, with no files, people or history, Import cases on screen is simpler.
The full approach, stage by stage (discovery, mapping, cleansing, test migration, migration, validation and sign-off), is in the repository's docs/05-migration.md.
What it does
The tool reads a manifest: a spreadsheet saved as CSV with one row per case. For each row it opens the case through the public API, keeping its old reference, the date it was opened, the status it reached and who has it, and uploads every file in the case's folder, and in folders below it, as a document on the case.
- It runs where the files are, on a machine that can read the network drive, and talks to the API like any other system, with an API client's secret. It never touches the database, so every rule the screens apply holds.
- A dry run checks everything and sends nothing: every row against the case types, every case by the server exactly as it would open it, and every file against the kinds and sizes the server takes.
- A run can be stopped and started again. A journal records each case opened and each file sent, so running the same command again carries on and never does anything twice. If an answer is lost, so the tool cannot tell whether something arrived, the server still keeps it once: a case by its case type and old reference, a file by its name and contents on the case, a note or history entry by when, who and what. A row with no old reference has nothing to be known by, so give every row one. Two rows of one case type with the same old reference are a problem in the manifest.
- Time limits count from the dates the case gives and stop on its closing date. A time limit that starts on reaching a status runs from the day a case moved, if it moved in at that status: nothing says when it got there in the old system.
- Every file is accounted for. The reconciliation lists each file with its SHA-256 on the drive, compared with the one the server stored, what happened to it and the document it became.
The manifest
One row per case, columns in any order:
| Column | Needed | What it holds |
|---|---|---|
case_type | Yes | The case type's key, such as litigation |
title | Yes | The case's title |
legacy_reference | The old reference. It shows on the case and the cases list finds it. | |
opened_on | The date it was opened, as 2024-03-31 or 31/03/2024 | |
status | The status it reached, by name or key | |
closed_on | For a closed case, the date it closed | |
assign_to | The email address of the member who has it | |
folder | The case's folder, under the files folder given to the tool | |
detail.<key> | A detail: a choice by name, a date as above, yes or no, several choices separated by semicolons, an address's lines separated by | | |
party.<role>.<field> | Someone in a role: first_name, last_name, organisation, email, phone, address, postcode, date_of_birth |
Someone whose email address is already held is that record. So is an organisation of the same name, ignoring capitals, unless the row's email address or postcode differs. Spell each organisation the same on every row, since records cannot be merged afterwards. People are never matched by name.
Notes and history
A second spreadsheet, given with --history, brings each case's notes and history at their own dates, so the case reads as it did. One row per entry, matched to its case by legacy_reference, with at (when, in UK time), by (who, as the old system named them), text and kind (note for a note nobody can edit; otherwise a history entry).
Running it
- Create an API client with permission to see, open, change and import cases.
- On the machine that can read the files:
bash
export GENERA_API_KEY=ak_…
genera-migrate --api https://cases.example.gov.uk/ --manifest cases.csv --files /mnt/legal --history history.csv --out migration --dry-run- Once the dry run is clean, run the same command without
--dry-run. - Check the reconciliation, then stop the API client under Admin → API clients.
The output folder holds problems.csv (what is wrong with the manifest, by line and column), dry-run-files.csv (every file and whether it would be accepted), journal.csv (what has been done) and reconciliation.csv (every file, its SHA-256, its outcome and its document, and each case's history).
The tool exits with 0 when everything came across, 1 when something did not (see the reconciliation), 2 for a mistake in how it was started and 3 when it was stopped.