Skip to content

Program Mongoose migrations - #98

Open
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-program
Open

Program Mongoose migrations#98
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-program

Conversation

@AustinSMueller

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Program model + Mongoose-backed ProgramDAO, 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 Program APIs 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

  • createProgram validates params.name with .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.

Comment thread apps/backend/dao/program.js
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
AustinSMueller marked this pull request as ready for review July 30, 2026 16:40
@AustinSMueller
AustinSMueller requested a review from n2iw July 30, 2026 16:43
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.

2 participants