Program Mongoose migrations - #98
Open
AustinSMueller wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates “program/organization” data access in the backend from Prisma-centric patterns to Mongoose-backed DAOs, while renaming the service layer from Organization to Program and updating dependency injection throughout the runtime and tests.
Changes:
- Introduces a Mongoose
Programmodel + Mongoose-backedProgramDAO, and wires these into services/DAOs that previously relied on Prisma or native collections. - Renames organization-facing services/params to program equivalents across backend services, GraphQL router wiring, and tests.
- Updates test suites/mocks to match the new
ProgramAPIs and DAO methods (findById,getProgramByID, etc.).
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/db-driver/constants/organization-constants.js | Renames exported constants namespace from ORGANIZATION to PROGRAM. |
| apps/backend/verifier/user-info-verifier.js | Removes unused organization constants import. |
| apps/backend/test/services/submission.service.test.js | Updates constructor arg naming and ProgramDAO mocking (findById). |
| apps/backend/test/services/submission.processSubmissionNodes.data-view.test.js | Renames organization-service mock to program-service mock in constructor wiring. |
| apps/backend/test/services/submission.listPotentialCollaborators.test.js | Renames mock dependency from organizationService to programService. |
| apps/backend/test/services/submission.getUploaderCLIConfig.test.js | Renames constructor dependency from organizationService to programService. |
| apps/backend/test/services/submission.getSubmissionSummary.test.js | Renames organization service mock to program service mock. |
| apps/backend/test/services/submission.getDataFileConfigs.test.js | Updates mock naming/comments for program service injection. |
| apps/backend/test/services/submission.editSubmissionCollaborators.test.js | Renames organization service mock to program service mock. |
| apps/backend/test/services/submission.createBatch.test.js | Renames organization service mock to program service mock. |
| apps/backend/test/services/submission._notifyConfigurationChange.test.js | Updates Submission constructor arg position/name for program service. |
| apps/backend/test/services/program.service.test.js | Converts tests from Organization service to Program service + PROGRAM constants. |
| apps/backend/test/services/data-submission.test.js | Updates tests to use Program service and PROGRAM statuses. |
| apps/backend/test/services/approved-studies.test.js | Renames organizationService to programService and updates called methods. |
| apps/backend/test/services/approved-studies-notification-error-handling.test.js | Renames organizationService to programService in notification error handling tests. |
| apps/backend/test/services/application.test.js | Updates Application service tests to depend on programService. |
| apps/backend/test/services/application.remindApplicationSubmission.test.js | Renames injected organizationService to programService. |
| apps/backend/test/services/application.deleteInactiveApplications.test.js | Renames injected organizationService to programService. |
| apps/backend/test/graphql-queries/edit-organization.test.js | Switches GraphQL query test to instantiate Program service. |
| apps/backend/test/graphql-queries/delete-inactive_submission.test.js | Updates submission integration-style test wiring to use programService. |
| apps/backend/test/graphql-queries/batch-job.test.js | Renames organizationService mock to programService mock across services. |
| apps/backend/test/dao/dao.submission.test.js | Updates SubmissionDAO tests to mock the new ProgramDAO dependency. |
| apps/backend/test/dao/dao.program.test.js | Rewrites ProgramDAO tests to target Mongoose model behavior (findOne/findById/aggregate/upsert). |
| apps/backend/services/submission.js | Renames injected organizationService to programService and switches program lookup to ProgramDAO.findById. |
| apps/backend/services/program-service.js | Renames Organization service to Program, updates APIs (get/edit/create) and uses Mongoose-backed ProgramDAO. |
| apps/backend/services/approved-studies.js | Replaces organizationService usage with programService and swaps ProgramDAO construction to Mongoose-backed DAO. |
| apps/backend/services/application.js | Renames organizationService to programService and updates program upsert/lookup calls. |
| apps/backend/routers/graphql-router.js | Wires GraphQL resolvers to Program service while retaining GraphQL field names (e.g., getOrganization). |
| apps/backend/mongoose/models/program.js | Adds Mongoose schema/model for programs stored in the historical organization collection. |
| apps/backend/dao/submission.js | Updates organization list retrieval to use Mongoose ProgramDAO and PROGRAM status constants. |
| apps/backend/dao/program.js | Replaces Prisma-based DAO with a MongooseGenericDAO-backed ProgramDAO (lookup + list + upsert). |
| apps/backend/app.js | Switches runtime wiring from Organization service to Program service for submission/application/approved-studies flows. |
Comments suppressed due to low confidence (1)
apps/backend/services/program-service.js:323
createProgramvalidatesparams.namewith.trim()but then persists the untrimmed string (newOrg.name = params.name). This can store leading/trailing whitespace in the DB and bypass the duplicate-name check (which queries by trimmed name), creating hard-to-find near-duplicates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Return null early when the name argument is null, undefined, or whitespace-only, avoiding an unnecessary database query. Also adds a test case for whitespace-only input.
AustinSMueller
marked this pull request as ready for review
July 30, 2026 16:40
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.
No description provided.