[PR #3550] [CLOSED] feat: run database migration on backend start up #4429

Closed
opened 2026-03-17 01:57:56 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/3550
Author: @mirarifhasan
Created: 11/14/2023
Status: Closed

Base: release/2023.12.0Head: feat/migrate-on-startup


📝 Commits (1)

  • fe1d700 feat: script command added in package.json

📊 Changes

4 files changed (+7 additions, -4 deletions)

View changed files

📝 aio_run.mjs (+1 -1)
📝 packages/hoppscotch-backend/Dockerfile (+2 -2)
📝 packages/hoppscotch-backend/package.json (+3 -0)
📝 prod.Dockerfile (+1 -1)

📄 Description

Closes HBE-313

Description

Previously we needed to run pnpx prisma migrate dev --name something to run database migration after container starts.
The drawback is, to run the migration command, the backend container must be in running state.

This brings an issue that, if anyonModuleInit needs to read from database, and database has not migrated earlier, thenonModuleInit fails as well as backend container fails to start. Since backend container fails to start, you can not run pnpx prisma migrate .... command by docker exec ....

In this PR, we introduce a script in the backend package.json to run migration before the backend container startup.
This way, you do not need to run pnpx prisma migrate ... anymore. During the container startup, migration will be executed itself.

Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

Additional Information

Nil


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/3550 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 11/14/2023 **Status:** ❌ Closed **Base:** `release/2023.12.0` ← **Head:** `feat/migrate-on-startup` --- ### 📝 Commits (1) - [`fe1d700`](https://github.com/hoppscotch/hoppscotch/commit/fe1d7005b54aa56cbc82a13a4d43d32f3e8cab3c) feat: script command added in package.json ### 📊 Changes **4 files changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `aio_run.mjs` (+1 -1) 📝 `packages/hoppscotch-backend/Dockerfile` (+2 -2) 📝 `packages/hoppscotch-backend/package.json` (+3 -0) 📝 `prod.Dockerfile` (+1 -1) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes HBE-313 ### Description <!-- Add a brief description of the pull request --> Previously we needed to run `pnpx prisma migrate dev --name something` to run database migration after container starts. The drawback is, to run the migration command, the backend container must be in running state. This brings an issue that, if any`onModuleInit` needs to read from database, and database has not migrated earlier, then`onModuleInit` fails as well as backend container fails to start. Since backend container fails to start, you can not run `pnpx prisma migrate ....` command by `docker exec ...`. In this PR, we introduce a script in the backend `package.json` to run migration before the backend container startup. This way, you do not need to run `pnpx prisma migrate ...` anymore. During the container startup, migration will be executed itself. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Checks <!-- Make sure your pull request passes the CI checks and do check the following fields as needed - --> - [x] My pull request adheres to the code style of this project - [x] My code requires changes to the documentation - [ ] I have updated the documentation as required - [x] All the tests have passed ### Additional Information <!-- Any additional information like breaking changes, dependencies added, screenshots, comparisons between new and old behaviour, etc. --> Nil --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 01:57:56 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4429
No description provided.