Skip to content

feat: Delete unused Postgres backend (dead code) - Issue #41#86

Open
anota-fernandocosta wants to merge 8 commits into
mainfrom
feature/issue-41-delete-postgres-backend
Open

feat: Delete unused Postgres backend (dead code) - Issue #41#86
anota-fernandocosta wants to merge 8 commits into
mainfrom
feature/issue-41-delete-postgres-backend

Conversation

@anota-fernandocosta

Copy link
Copy Markdown
Contributor

Description

Deletes the unused Postgres backend implementation from the codebase. The Postgres backend implemented the same Requests interface as MongoDB but was never wired up in production (the docker-compose Postgres service was commented out).

Changes

Deleted (US-001 through US-008):

  • US-001: Deleted entire api/db/postgres/ directory (5 files: postgres_handler.go, sql.go, types.go, sql_test.go, postgres_suite_test.go)
  • US-002: Deleted api/db/psqlretriever.go (SQLJSONRetrieve adapter with lib/pq dependency)
  • US-003: Deleted api/db/postgres.go and api/db/postgres_test.go (PostgresRequests implementation + tests)
  • US-004: Cleaned api/db/types.go — removed Postgres-only types (DataGenerator, SQLJSONRetrieve, PostgresRequests); preserved Requests, MongoRequests, JSON, JSONCaller
  • US-005: Simplified api/context/context.go::GetDB — removed Postgres branch, now always returns &db.MongoRequests{}
  • US-006: Deleted deployments/dockerfiles/postgres.Dockerfile and deployments/huskyci.sql; removed commented-out Postgres service from deployments/docker-compose.yml
  • US-007: Updated CLAUDE.md — states MongoDB is the supported production store, db.Requests preserved for abstraction/testability
  • US-008: Ran go mod tidy in api/ — removed github.com/lib/pq from go.mod and go.sum

What remains:

  • db.Requests interface (api/db/huskydb.go) — preserved for abstraction and testability
  • MongoRequests struct (api/db/types.go) — the active MongoDB implementation
  • All behavioral contracts intact (client exit code 190, token rejection, input validators, scanner command substitution, K8s WaitPod)

Testing

  • cd api && go vet ./... — passes cleanly
  • cd api && go test -race -count=1 ./... — all 10 test packages pass, no race conditions
  • Per-module independence verified — client/go.mod and cli/go.mod unchanged

Closes #41

anota-fernandocosta and others added 8 commits June 19, 2026 16:45
…layer)

Remove all 5 files in api/db/postgres/: postgres_handler.go, sql.go,
types.go, sql_test.go, and postgres_suite_test.go. These are dead code
only referenced by other Postgres-deletion targets (psqlretriever.go
and context.go). Builds will temporarily break until subsequent stories
fix the callers.

Co-Authored-By: Tamandua <tamandua@tetradactyla.org>
Removes the Postgres data retrieval adapter containing:
- ConvertStringToSlice helper function
- SQLJSONRetrieve methods (Connect, RetrieveFromDB, WriteInDB, PqArray)
- Import of github.com/lib/pq

This file had a broken import of the already-deleted postgres.SQLGen type.

Co-Authored-By: Tamandua <tamandua@tetrandactyla.org>
Removed the PostgresRequests implementation methods and standalone
query builder functions (ConfigureQuery, ConfigureInsertQuery,
ConfigureUpdateQuery, ConfigureUpsertQuery) along with all their tests.

These files are dead code after US-001 (deleted api/db/postgres/)
and US-002 (deleted api/db/psqlretriever.go).

Co-Authored-By: Tamandua <tamandua@tetrandactyla.org>
- Removed import of deleted github.com/githubanotaai/huskyci-api/api/db/postgres
- Removed DataGenerator interface (only implemented by SQLJSONRetrieve, already deleted)
- Removed SQLJSONRetrieve struct (only used by Postgres code, already deleted)
- Removed PostgresRequests struct (only used by Postgres code, already deleted)
- Preserved: Requests interface, MongoRequests struct, JSON interface, JSONCaller struct
- go vet ./db/ passes; go test -race ./db/ passes

Co-Authored-By: Tamandua <tamandua@tetrandactyla.org>
Remove the Postgres import and GetDB condition branch so that
GetDB unconditionally returns &db.MongoRequests{}. The Postgres
backend was already deleted in prior stories (US-001 through US-004).

Co-Authored-By: Tamandua <tamandua@tetrandactyla.org>
- Remove commented-out postgres service block from deployments/docker-compose.yml
- Delete deployments/dockerfiles/postgres.Dockerfile
- Delete deployments/huskyci.sql (PostgreSQL database dump)

No remaining references to postgres deployment artifacts exist in the repo.
All api tests pass.

Co-Authored-By: Tamandua <tamandua@tetradactyla.org>
Remove Postgres backend mention and update database paragraph to state
MongoDB is the supported production store, with db.Requests preserved
for abstraction and testability.

Co-Authored-By: Tamandua <tamandua@tetradactyla.org>
- Ran go mod tidy to remove github.com/lib/pq from api/go.mod and api/go.sum
- Applied gofmt formatting to 8 files
- go vet ./... passes cleanly
- golangci-lint shows only pre-existing issues (sha3 inlining in authmongo.go)
- go test -race -count=1 ./... all 11 test packages pass
- client/go.mod and cli/go.mod unchanged

Co-Authored-By: Tamandua <tamandua@tetrandactyla.org>
@anota-fernandocosta anota-fernandocosta requested a review from a team as a code owner June 19, 2026 20:28

@anota-fernandocosta anota-fernandocosta left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approve ✅

This is a clean, well-executed dead code removal. All 8 user stories are completed, the diff is focused, and no behavioral contracts are broken.

What was removed (10 files, ~3,000 lines):

  • api/db/postgres/ (5 files): innermost Postgres implementation
  • api/db/postgres.go + api/db/postgres_test.go: PostgresRequests and tests
  • api/db/psqlretriever.go: SQLJSONRetrieve adapter with lib/pq dependency
  • deployments/dockerfiles/postgres.Dockerfile + deployments/huskyci.sql: deployment artifacts
  • Commented-out Postgres service in docker-compose.yml

What was modified correctly:

  • api/context/context.go: Postgres import + entire GetDB Postgres branch removed. Function now unconditionally returns &db.MongoRequests{}. strings import correctly preserved (still used elsewhere).
  • api/db/types.go: DataGenerator, SQLJSONRetrieve, PostgresRequests removed. Requests, MongoRequests, JSON, JSONCaller preserved. time import correctly preserved (used in Requests interface).
  • api/go.mod + go.sum: github.com/lib/pq removed. golang.org/x/net correctly moved to indirect (only needed by k8s.io deps now).
  • CLAUDE.md: Updated to state MongoDB is the supported production store, db.Requests preserved for abstraction/testability.
  • deployments/docker-compose.yml: Postgres service block fully removed.

Incidental gofmt fixes (all benign):

  • api/auth/types.go, api/context/context_test.go, api/context/gitleaks_env_test.go, api/securitytest/gitleaks_severity.go, api/securitytest/run_test.go, api/securitytest/runner.go, api/securitytest/securitycodescan.go, api/types/types.go: formatting/alignment fixes

CI: All 8 checks pass

Build & Test (api, cli, client) ✅ | Lint ✅ | Docker Build (api, client) ✅ | Deployment shell ✅ | Gitleaks ✅

Non-blocking note:

JSON interface, JSONCaller struct, and api/db/jsoncaller.go are no longer referenced by any production or test code after the Postgres removal. The task spec preserves them — a reasonable choice. Worth considering for a future cleanup pass if they remain unused.

Verdict:

No bugs, no regressions, no missed references. The removal is thorough and the diff is clean. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[09/48] Delete unused Postgres backend (dead code)

1 participant