[HOTE-1080] feat: Move goose migrator lambda to service repo#403
[HOTE-1080] feat: Move goose migrator lambda to service repo#403
Conversation
There was a problem hiding this comment.
Pull request overview
Moves the Goose database migrator Lambda into this service repo, alongside its migration set and developer/CI tooling to build and validate migrations.
Changes:
- Added a Go-based
goose-migrator-lambda(handler + Go module files) and packaged migrations. - Added local scripts to build the Lambda zip and to test migrations against a local Postgres container.
- Wired migration testing into CI and updated repo tooling/docs/ignores to support the new Lambda.
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
lambdas/goose-migrator-lambda/src/main.go |
Implements the Go Lambda handler to run Goose migrations and manage schema/user setup. |
lambdas/goose-migrator-lambda/src/go.mod |
Adds a standalone Go module for the migrator Lambda. |
lambdas/goose-migrator-lambda/src/go.sum |
Locks Go dependency checksums for the migrator Lambda. |
lambdas/goose-migrator-lambda/scripts/build.sh |
Adds a build/packaging script that produces the Lambda zip and caches builds via hashing. |
lambdas/goose-migrator-lambda/scripts/test-migrations.sh |
Adds a Docker-based migration test script to validate migrations and privileges. |
lambdas/goose-migrator-lambda/migrations/000001_create_initial_home_test_tables.sql |
Adds initial schema migration for the migrator’s migration set. |
lambdas/goose-migrator-lambda/migrations/000002_seed_home_test_data.sql |
Adds a seed-data migration for suppliers and related config. |
lambdas/goose-migrator-lambda/migrations/000003_add_order_status_columns.sql |
Adds order status correlation ID column and index. |
lambdas/goose-migrator-lambda/migrations/000004_static_data.sql |
Seeds static reference data (status/result types). |
lambdas/goose-migrator-lambda/migrations/000005_seed_test_type.sql |
Seeds test_type reference data. |
lambdas/goose-migrator-lambda/migrations/000006_supplier_data_update.sql |
Updates supplier service URLs. |
lambdas/goose-migrator-lambda/migrations/000007_supplier_data_update.sql |
Updates supplier OAuth client ID data. |
lambdas/goose-migrator-lambda/migrations/000008_schema_per_environment.sql |
Adds pgcrypto extension setup for schema-per-environment approach. |
lambdas/goose-migrator-lambda/migrations/000009_update_supplier_endpoints.sql |
Adds/updates supplier endpoint path columns and values. |
lambdas/goose-migrator-lambda/migrations/000010_update_order_status_codes.sql |
Renames status codes with temporary FK constraint changes. |
lambdas/goose-migrator-lambda/migrations/000011_add_consent_table.sql |
Adds consent table and constraints. |
lambdas/goose-migrator-lambda/migrations/000012_add_la_supplier_offering.sql |
Seeds supplier offerings. |
lambdas/goose-migrator-lambda/migrations/000013_remove_order_reference_from_order_status.sql |
Removes order_reference from order_status. |
lambdas/goose-migrator-lambda/migrations/000014_add_notification_audit_table.sql |
Adds notification audit table + indexes. |
lambdas/goose-migrator-lambda/migrations/000015_create_session_table.sql |
Adds session table for auth/session storage. |
lambdas/goose-migrator-lambda/migrations/000016_add_order_status_reminder_table.sql |
Adds order status reminder tracking table/type/index. |
lambdas/README.md |
Documents the new Go migrator Lambda structure and how to build/test it. |
.mise.toml |
Adds mise tasks for migration testing and adds a Go tool version. |
.gitleaksignore |
Suppresses gitleaks false-positives for secret path names in new migrations. |
.gitignore |
Ignores Go migrator build artifacts (zip, bootstrap binary, cache). |
.github/workflows/stage-2-test.yaml |
Adds a CI job to run the new goose migration tests. |
25b43bd to
695f504
Compare
695f504 to
b0ef41c
Compare
d5bbd7a to
673fa96
Compare
cf26663 to
4cc217c
Compare
fb4fc8b to
bded055
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 32 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
lambdas/goose-migrator-lambda/migrations/000015_create_session_table.sql:6
- This migration was changed from
CREATE TABLE IF NOT EXISTStoCREATE TABLE, which makes it non-idempotent and more brittle in environments where the table may already exist (e.g., partial restores or manual bootstrap); keepIF NOT EXISTS(or ensure the down migration is always run first in the same workflow).
lambdas/goose-migrator-lambda/migrations/000015_create_session_table.sql:32 - The
CREATE INDEXstatement no longer usesIF NOT EXISTS, so rerunning the migration in a partially-initialised database will fail with “already exists”; useCREATE INDEX IF NOT EXISTS(Postgres 9.5+) to keep behavior consistent with other migrations in this repo.
bded055 to
4de361b
Compare
4de361b to
bcca382
Compare
33fb769 to
1195656
Compare
f74cd21 to
a536263
Compare
357f744 to
526e84a
Compare
|
TL;DR:
Previously the seed script duplicated supplier rows (Preventx as c1a2b3c4-..., SH:24 as d2b3c4d5-...) that only existed locally. API tests now reference the same supplier that exists in every environment. |
526e84a to
01c0481
Compare
…flicts, fix read only volume issue in docker compose
…URL and goose dialect in go file
…ude main.go from sonar analysis
…n the goose migrations
01c0481 to
aa56735
Compare
|



Description
https://nhsd-jira.digital.nhs.uk/browse/HOTE-1080
The new approach makes the seed script responsible only for what it should own: environment-specific overrides, patching service_url, oauth_token_path, order_path, and client_secret_name to local WireMock values via an UPDATE
Goose migrations (000002, 000009) become the canonical source of truth, they own supplier creation and UUIDs; the seed patches
Context
Previously, the goose-migrator Lambda (Go source code, SQL migrations, along with build and test scripts) lived in the terraform repo, creating a split where application database migrations were owned by the infrastructure repo rather than the service repo.
This PR moves the Lambda into the service repo - close to the application code which depends on the migrations, making it the single source of truth for them all.
Terraform continues to own IAM, VPC config, and Lambda invocation - it calls the build script from the service repo at deploy time.
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.