refactor(api): remove MongoDB store, keep Postgres as sole implementation#6429
Merged
Conversation
…tion The Mongo->Postgres migration is finalized, so the MongoDB store and the one-time data-migration tool are removed. The store.Store interface is preserved with PostgreSQL as the only implementation. Store construction is now pg-only: the DATABASE switch, the "migrate" mode (and its unauthenticated /api/migration/status endpoint), and MONGO_URI are gone from the api server and cli. Unknown database errors are now wrapped in the new store.ErrInternal so the echo error handler keeps reporting them to Sentry as 500s; context cancellation/deadline errors pass through unwrapped to avoid noise. The dead mongo.ErrUserNotFound branch in removeMember is dropped (the FindMember precheck already handles absent members).
|
Claude finished @otavio's task in 6m 23s —— View job Code Review CompleteReviewed 23 modified/added files across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is. Review highlights:
To request another review round, comment |
gofumpt formatting in utils_test.go and an nlreturn blank line before break in cleanup_test.go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes the entire MongoDB store implementation and the one-time Mongo→Postgres data-migration tool, leaving the
store.Storeinterface in place with PostgreSQL as the only implementation.This must merge together with the companion PR in shellhub-io/cloud (branch
feat/remove-mongodb-store). Cloud builds against this repo viareplace => ../shellhuband imports the now-deletedapi/store/mongoandapi/store/migratepackages. Merging this alone breaks cloudmain/CI until the cloud PR lands. Coordinate the merges.Why
The Mongo→Postgres migration is finalized; the MongoDB backend and its migration code are dead weight. The interface abstraction is intentionally preserved so a future backend remains possible.
Changes
api/store/mongo/(impl + 119 migrations),api/store/migrate/(incl.RegisterMigrationExtension),storetest/mongoprovider/, andapi/pkg/dbtest/. Kept thestore.Storeinterface, mocks, the genericstoretestharness,RegisterStoreWrapper, andpg/internallegacyMongoFieldMapping.DATABASEswitch, themigratemode (and its unauthenticatedGET /api/migration/statuslistener), andMONGO_URI. The cli keeps its existing pg options and does not run migrations.store.ErrInternal(unique error code).pg.fromSQLErrorwraps unmapped errors with it so the echo handler keeps reporting unknown DB errors to Sentry as 500s;context.Canceled/DeadlineExceededpass through unwrapped to avoid alert noise. Removed the deadmongo.ErrUserNotFoundbranch inremoveMember— absent members are already caught by theFindMemberprecheck.go mod tidydroppedmongo-driver,mongotest,mongo-lock,mongo-migrate, and the mongodb testcontainers module;modules/postgresretained.docker-compose.mongo*.yml, the mongo leg ofbin/docker-compose,MONGO_URIfrom the enterprise compose, and thedatabase: mongoqa matrix entry (postgres leg kept).Testing
go build ./...andgo vet ./...clean inapi/andcli/.fromSQLErrorwrapping vs. context-error passthrough; the handler reportingErrInternal(and not reportingErrNoDocuments/context.Canceled); and theremoveMemberprecheck path.pgstoretest suite (proof the pg store still satisfies the full interface) passes in the dev stack.Follow-up
The
docsrepo upgrade guide (self-hosted/upgrading.md) still references the removedGET /api/migration/statusendpoint — separate docs PR.