30 lines
1.4 KiB
Markdown
30 lines
1.4 KiB
Markdown
cmd/migratecheck — run the real migration against a throwaway Postgres.
|
|
|
|
The test suite never calls migrations.Migrate(): the integration tests
|
|
AutoMigrate only the models they need. So every raw statement at the end of
|
|
migrations/migrate.go — CREATE EXTENSION, the views, the indexes, the registry
|
|
seed — was unexecuted until this existed, and Migrate() logs those failures
|
|
NON-FATALLY. A broken view therefore returned "migration completed
|
|
successfully" and failed later at query time.
|
|
|
|
That is not hypothetical: it caught `bd.destinationid` (the real column is
|
|
bookingdestinationid), which would have left consignment_booking uncreated and
|
|
every query that joins through it failing in production.
|
|
|
|
Run it before shipping a migration change:
|
|
|
|
docker run -d --name dm-testpg -e POSTGRES_PASSWORD=test -e POSTGRES_DB=logistics \
|
|
-p 55432:5432 pgvector/pgvector:pg16
|
|
docker exec dm-testpg psql -U postgres -d logistics -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
|
|
MIGRATE_CHECK_DSN="host=localhost port=55432 user=postgres password=test dbname=logistics sslmode=disable" \
|
|
go run ./cmd/migratecheck
|
|
|
|
Check the OUTPUT, not just the exit code — Migrate() returns OK on a logged
|
|
failure. Any ❌ or ⚠️ line is a statement that did not run.
|
|
|
|
The same DSN unskips 50 Postgres integration tests:
|
|
|
|
REGISTRY_TEST_DSN="host=localhost port=55432 user=postgres password=test dbname=logistics sslmode=disable" \
|
|
go test ./... -count=1
|