Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(migrations): support for running database migrations manually #2622

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

golobitch
Copy link
Collaborator

@golobitch golobitch commented Mar 30, 2024

Changes proposed in this pull request

  • Introduce new environmental variable ENABLE_MANUAL_MIGRATIONS through which end user can decide if he/she wants to run migrations automatically (default flow as it always was) or manually (pnpm run knex -- migrate:latest --env production
  • In knexfile.js use env variable from the ENV for setting connection string for production environment
  • In dockerfile, copy knexfile.js from source to container

With this in place, if Rafiki is installed on kubernetes cluster, it is possible to leverage initContainers for database migrations. This should be backward compatible or in other words, should not change how Rafiki deals with database migrations when default values for this environment variable is set.

Context

fixes #2621

After this PR is merged, we will need to implement this ENV into helm charts. After this ENV is added to helm charts, we need to set value to true, and we will also need to specify initContainer that will run this migrations "manually" or in other words, automatically in initContainer.

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Documentation added
  • Make sure that all checks pass
  • Bruno collection updated

@golobitch golobitch self-assigned this Mar 30, 2024
@github-actions github-actions bot added pkg: backend Changes in the backend package. type: source Changes business logic pkg: auth Changes in the GNAP auth package. pkg: documentation Changes in the documentation package. type: documentation (archived) Improvements or additions to documentation labels Mar 30, 2024
Copy link

netlify bot commented Mar 30, 2024

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit 1213094
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/6609273564659f0008f7a972

@golobitch golobitch force-pushed the fix/2621-db-migrations-k8s branch 3 times, most recently from 42d4eb6 to ad4cd3c Compare March 30, 2024 20:59
@@ -17,6 +17,7 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
FROM base AS prod-deps

COPY package.json pnpm-workspace.yaml .npmrc ./
COPY packages/auth/knexfile.js ./packages/auth/knexfile.js
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this line here is not really needed (same for packages/backend/Dockerfile however, I like consistency (line #55)

@golobitch golobitch force-pushed the fix/2621-db-migrations-k8s branch from ad4cd3c to 1213094 Compare March 31, 2024 09:04
@golobitch
Copy link
Collaborator Author

This PR has been approved, however, I am not authorized to merge this pull request.

Copy link
Member

@sabineschaller sabineschaller left a comment

Choose a reason for hiding this comment

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

Thank you!

@sabineschaller sabineschaller merged commit ae859a9 into main Apr 2, 2024
23 checks passed
@sabineschaller sabineschaller deleted the fix/2621-db-migrations-k8s branch April 2, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: auth Changes in the GNAP auth package. pkg: backend Changes in the backend package. pkg: documentation Changes in the documentation package. type: documentation (archived) Improvements or additions to documentation type: source Changes business logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] k8s pod is in running state if database migration fails
4 participants