feat(api): one-time legacy catalogue import, KWS_MODE=seed (#7) #151

Merged
amiryahaya merged 1 commit from feat/legacy-catalogue-import into main 2026-11-03 12:58:58 +01:00
Owner

Closes part of #7: the one-time import of the legacy catalogue. Design: docs/superpowers/specs/2026-11-03-legacy-catalogue-import-design.md.

What it does

  • api/cmd/legacy-export reads the legacy pg_dump (250205.sql) only for allowlisted catalogue tables (legacyimport.Tables), line by line; sales, tickets, users, visitor answers and Medias are never read or held.
  • It writes api/internal/legacyimport/seed/catalogue.sql (plain INSERTs, ids from uuidv7() through a temp map, no legacy ids stored) and REVIEW.md (counts and every quirk).
  • KWS_MODE=seed loads the embedded seed once, after migrate, in one transaction. It is refused (ErrNotEmpty) if any catalogue table has rows.
  • Loaded: 2 category types, 18 categories, 7 park categories, 16 parks, 29 gates, 7 forms, 13 form inputs, 34 products, 237 park products, 424 historical fees, 190 fees carried forward, 1 setting.

Owner ruling applied

  • Fees carried forward: every legacy fee expired by 2023-06-30. The history comes across unchanged, and each latest active fee starts again from the load day to 31 December (Nairobi dates, computed in SQL at load).

My calls (please check)

  • Seed mode, not a migration (a migration would put the parks into every test DB and could never change).
  • Not imported: photos (dead blob URLs, rights unchecked), currency rates (all expired, direction looks inverted), the Email/BCC Email notification settings (staff set them), dictionaries, roles.
  • Products L7–L12 had no code and get L<legacy id>. Park codes 701 and 702 stay on the oldest park; "Lake Nakuru" and "Mt. Longonot N. Park" get none.
  • Form inputs map by label (the legacy input-type enum is in a compiled package). Age group comes from the product name.
  • Fee valid_from moves to the next day when its time is 12:00 or later (rows written in UTC+3/UTC+8).
  • Park HTML becomes the light Markdown of #45; plain-text fields keep their lines; malformed mailto: links keep only their text.

Owner questions

  • Five parks are inactive in the legacy data and stay so: Nairobi National Park, Amboseli, Lake Nakuru (both rows), Hell's Gate. The public site lists 11 parks.
  • Trucks, boats, the motorcycle, bicycles and guided tours are park_entry products (as in legacy), not vehicle.
  • 14 duplicate product codes (000, 041, 004, 005, 123) are listed in REVIEW.md, not changed.
  • Convenience fee 7.3 is imported as a percent.

Checks

  • make cover: 91.6 % total (legacyimport 92.5 %, app 92.1 %); make lint clean; gitleaks clean on the new package.
  • Tried on a fresh dev DB: migrate, seed (614 fees), a second seed refused, public GET /v1/parks lists the 11 active parks. A test now checks every REVIEW.md count against the loaded DB and the public parks list.
  • Dual-pass review: Ponytail (one fix: a missing currency now fails the load instead of dropping fees) and an Opus review (fixed: bullets lost inside list items, an unvalidated duration value, the seed test's missing count/API checks; duplicate codes now noted).
  • Deferred minors: a table missing from the dump reads as empty; a link inside bold loses its link; only parks is locked; no explicit standard_conforming_strings; the convenience fee is not checked against the settings rules.

Deploy

Run once at go-live: KWS_MODE=migrate, then KWS_MODE=seed. Not in CI and not automatic.

🤖 Generated with Claude Code

Closes part of #7: the one-time import of the legacy catalogue. Design: `docs/superpowers/specs/2026-11-03-legacy-catalogue-import-design.md`. ## What it does - `api/cmd/legacy-export` reads the legacy `pg_dump` (250205.sql) **only for allowlisted catalogue tables** (`legacyimport.Tables`), line by line; sales, tickets, users, visitor answers and `Medias` are never read or held. - It writes `api/internal/legacyimport/seed/catalogue.sql` (plain INSERTs, ids from `uuidv7()` through a temp map, no legacy ids stored) and `REVIEW.md` (counts and every quirk). - `KWS_MODE=seed` loads the embedded seed once, after `migrate`, in one transaction. It is refused (`ErrNotEmpty`) if any catalogue table has rows. - Loaded: 2 category types, 18 categories, 7 park categories, 16 parks, 29 gates, 7 forms, 13 form inputs, 34 products, 237 park products, 424 historical fees, 190 fees carried forward, 1 setting. ## Owner ruling applied - **Fees carried forward:** every legacy fee expired by 2023-06-30. The history comes across unchanged, and each latest active fee starts again from the load day to 31 December (Nairobi dates, computed in SQL at load). ## My calls (please check) - Seed mode, not a migration (a migration would put the parks into every test DB and could never change). - **Not imported:** photos (dead blob URLs, rights unchecked), currency rates (all expired, direction looks inverted), the Email/BCC Email notification settings (staff set them), dictionaries, roles. - Products L7–L12 had no code and get `L<legacy id>`. Park codes 701 and 702 stay on the oldest park; "Lake Nakuru" and "Mt. Longonot N. Park" get none. - Form inputs map by label (the legacy input-type enum is in a compiled package). Age group comes from the product name. - Fee `valid_from` moves to the next day when its time is 12:00 or later (rows written in UTC+3/UTC+8). - Park HTML becomes the light Markdown of #45; plain-text fields keep their lines; malformed `mailto:` links keep only their text. ## Owner questions - Five parks are **inactive** in the legacy data and stay so: Nairobi National Park, Amboseli, Lake Nakuru (both rows), Hell's Gate. The public site lists 11 parks. - Trucks, boats, the motorcycle, bicycles and guided tours are `park_entry` products (as in legacy), not `vehicle`. - 14 duplicate product codes (000, 041, 004, 005, 123) are listed in REVIEW.md, not changed. - Convenience fee `7.3` is imported as a percent. ## Checks - `make cover`: **91.6 %** total (legacyimport 92.5 %, app 92.1 %); `make lint` clean; gitleaks clean on the new package. - Tried on a fresh dev DB: migrate, seed (614 fees), a second seed refused, public `GET /v1/parks` lists the 11 active parks. A test now checks every REVIEW.md count against the loaded DB and the public parks list. - Dual-pass review: Ponytail (one fix: a missing currency now fails the load instead of dropping fees) and an Opus review (fixed: bullets lost inside list items, an unvalidated duration value, the seed test's missing count/API checks; duplicate codes now noted). - Deferred minors: a table missing from the dump reads as empty; a link inside bold loses its link; only `parks` is locked; no explicit `standard_conforming_strings`; the convenience fee is not checked against the settings rules. ## Deploy Run once at go-live: `KWS_MODE=migrate`, then `KWS_MODE=seed`. Not in CI and not automatic. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(api): one-time legacy catalogue import, KWS_MODE=seed (#7)
All checks were successful
ci / changes (pull_request) Successful in 22s
ci / clients (pull_request) Has been skipped
ci / web (pull_request) Has been skipped
ci / api (pull_request) Successful in 16m9s
ci / ci-gate (pull_request) Successful in 4s
59c3873943
cmd/legacy-export reads only the allowlisted catalogue tables of the
legacy pg_dump and writes a reviewed seed (legacyimport/seed/catalogue.sql
and REVIEW.md). KWS_MODE=seed loads the embedded seed once, in one
transaction, into an empty catalogue; it is refused otherwise.

Park HTML becomes the light Markdown of #45, fee dates become Nairobi
days, and each latest active fee is carried forward from the load day to
31 December (owner). No sales, personal data, photos, rates or
notification emails are imported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!151
No description provided.