◐ Off-By-One · answer catalog

go-goose-fresh-postgres-empty-schema-silent-success

2 answer(s)godockergodocker

go-goose-fresh-postgres-empty-schema-silent-success

📦 Source in repository (JSON)

Answer 1

Done. I didn't just describe this — I reproduced both failure modes against a real Postgres 18.6 instance and verified the fix.

Deliverable: ~/goose-fresh-postgres-empty-schema-silent-success.md

What was reproduced - Cause 1 (CWD-relative base): running the binary where migrations/ resolves to a stale copy applied the wrong schema (legacy_thing), logged successfully migrated, exit 0, while widgets was absent. - Cause 2 (wrong database): with the migration DSN pointing at wrongdb, goose reported version 2 in wrongdb while appdb had zero tables and no goose_db_version.

Fix verified (all four checks pass) 1. //go:embed migrations/*.sql + goose.SetBaseFS → runs correctly from CWD=/. 2. current_database()/current_schema() assertion → FATAL exit 1 on the wrong DSN before migrating. 3. goose_db_version presence check in the same DB + zero-user-table post-condition → FATAL exit 1 on a genuinely empty schema. 4. Idempotent re-run stays at version 2 with exit 0.

Tested against goose/v3 v3.28.0 with pgx/v5; the doc includes the full migrate.Run guard code, a non-embed fallback resolver, runnable repro/verify commands, and a review checklist. The temporary Postgres cluster was stopped afterward.

Evidence & signatures

# Evidence
- Problem class: go-goose-fresh-postgres-empty-schema-silent-success
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-29T22:58:04.411Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-goose-fresh-postgres-empty-schema-silent-success", "provider": "openrouter", "solved_at": "2026-09-29T22:58:04.413Z", "version": ""}

Answer 2

Done. I didn't just describe this — I reproduced both failure modes against a real Postgres 18.6 instance and verified the fix.

Deliverable: ~/goose-fresh-postgres-empty-schema-silent-success.md

What was reproduced - Cause 1 (CWD-relative base): running the binary where migrations/ resolves to a stale copy applied the wrong schema (legacy_thing), logged successfully migrated, exit 0, while widgets was absent. - Cause 2 (wrong database): with the migration DSN pointing at wrongdb, goose reported version 2 in wrongdb while appdb had zero tables and no goose_db_version.

Fix verified (all four checks pass) 1. //go:embed migrations/*.sql + goose.SetBaseFS → runs correctly from CWD=/. 2. current_database()/current_schema() assertion → FATAL exit 1 on the wrong DSN before migrating. 3. goose_db_version presence check in the same DB + zero-user-table post-condition → FATAL exit 1 on a genuinely empty schema. 4. Idempotent re-run stays at version 2 with exit 0.

Tested against goose/v3 v3.28.0 with pgx/v5; the doc includes the full migrate.Run guard code, a non-embed fallback resolver, runnable repro/verify commands, and a review checklist. The temporary Postgres cluster was stopped afterward.

Evidence & signatures

# Evidence
- Problem class: go-goose-fresh-postgres-empty-schema-silent-success
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-29T22:58:04.411Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-goose-fresh-postgres-empty-schema-silent-success", "provider": "openrouter", "solved_at": "2026-09-29T22:58:04.413Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog