Repository navigation
Wire PostgreSQL migrations into deploy hook - #77
Merged
Merged
Conversation
Make db:migrate backend-aware so the shared hook preserves MongoDB deployments while applying PostgreSQL migrations before restart. Add stage-based deploy diagnostics, regression coverage, and deployment documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 25e0a7c2-d13b-4596-8100-df7bafb6e919
There was a problem hiding this comment.
Pull request overview
This pull request wires the shared db:migrate command into the github-master-hook deploy lifecycle so PostgreSQL migrations run before pruning dependencies and restarting services, while MongoDB deployments explicitly no-op. It also adds structured deploy-stage logging and documents the hook + PostgreSQL provisioning flow.
Changes:
- Add
migrateDatabase()to apply Drizzle migrations for PostgreSQL and no-op for MongoDB, with unit coverage. - Update
github-master-hookto runnpm run db:migrateafternpm ciand beforenpm prune --omit=dev, with stage/timing/commit logging and failure trapping. - Document the deploy hook lifecycle and PostgreSQL operational expectations in README + docs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/hooks.test.ts | Adds regression tests asserting hook ordering (migrate before prune/restart) and presence of stage/failure logging without shell tracing. |
| tests/database-migrations.test.ts | Adds unit tests for backend-aware migration behavior (MongoDB no-op, PostgreSQL applies, errors propagate). |
| src/db/postgres/migrations.ts | Introduces migrateDatabase() wrapper to route migrations based on resolved backend. |
| scripts/postgres-migrate.ts | Switches db:migrate entrypoint to call migrateDatabase() and print backend-appropriate completion messaging. |
| README.md | Documents deploy-hook lifecycle, ordering, and log expectations at a high level. |
| github-master-hook | Adds deploy stages, trap-based failure reporting, and runs db:migrate before pruning and restart steps. |
| docs/postgresql-deployment.md | Documents PostgreSQL provisioning/deploy behavior with the updated hook lifecycle and operational checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Log only the redacted migration error message so deploy failures do not emit stack traces, filesystem paths, or configured database URLs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 25e0a7c2-d13b-4596-8100-df7bafb6e919
Move migration error formatting into a side-effect-free module so unit tests do not load dotenv or application configuration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 25e0a7c2-d13b-4596-8100-df7bafb6e919
Remove the misleading import guard now that reusable error formatting lives in a side-effect-free module. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 25e0a7c2-d13b-4596-8100-df7bafb6e919
Match the repository's Node filesystem import convention in deploy-hook tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 25e0a7c2-d13b-4596-8100-df7bafb6e919
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.
Summary
db:migratecommand from the deploy hook after dependency installation and before pruning or service restartdb:migrateapply Drizzle migrations for PostgreSQL and explicitly no-op for MongoDBValidation
npm run test:unitnpm run type-checknpm run lint -- --quietbash -n github-master-hooknpm run db:migrateno-op executionReview