OSMAINT

Academy / Data and migration

Load in dependency order

Lesson 3 of 512 minProject leads, data owners, consultants

Goal

Use the import endpoints correctly and read the reject report instead of ignoring it.

OSMAINT imports equipment and inventory from semicolon-separated UTF-8 CSV, the same format as its exports, so export, edit and re-import round-trips. The import is row-by-row: a bad row is skipped and reported, and the rest are committed.

The order

  1. Organisation and sites.
  2. Functional locations.
  3. Equipment, with the Kod column as the required key.
  4. Inventory items and stock levels.
  5. PM schedules and job plans.
  6. Open work orders.
  7. Closed history, if you decided to keep it.

The equipment import

POST /api/import/equipment
Content-Type: text/csv; charset=utf-8
# semicolon-separated, header row required, column Kod is mandatory
# scope: equipment:write

The response reports imported, skipped and total, plus one error per rejected row with the row number and the raw data, so you can fix exactly those rows and re-upload. A duplicate code is skipped, not overwritten. A row with an unknown site name is rejected.

Reading the rejects

The reject file is the migration work queue. Do not re-run the whole import to fix three rows; fix the three rows and upload them. Because each row is independent and idempotent by code, a partial re-upload is safe.

Note

There is no automatic rollback of an import. Take a database backup before the first load, and load into a staging instance before production.

Verify

Import a ten-row equipment file with one deliberately broken row. Confirm nine are imported, one is rejected with a row number, and the error message names the problem.

Terms

Idempotent row
A row that can be applied twice without creating a duplicate, here because the code is the key.
Reject report
The per-row error list returned by the import, used as the fix queue.
Progress is stored in this browser only.

OSMAINT Academy · Data and migration · Load in dependency order · osmaint.org/academy/