Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ideal place/point in time to runmigrate?#60

Answeredbynickjj
SHxKM asked this question inQ&A
Discussion options

If I'm deploying on Railway, I need a way to runmigrate during the build process. I'm currently pointing Railway to an adjusted Dockerfile (they don't support docker-compose fully yet), and have the following indocker-entrypoint-web:

#!/usr/bin/env bashset -e# Always keep this here as it ensures your latest built assets make their way# into your volume persisted public directory.cp -r /public_collected /app# ADDITION 👉 Apply database migrationsecho "Apply database migrations"python manage.py migrateexec "$@"

However, this makes tasks like./run deps:install fail because they try to acquire a connection to the database to perform this action.

Any ideas where I can incorporate this?

You must be logged in to vote

Hi,

I treat migrations as a separate deploy step that's agnostic to how the app is deployed.

Ultimately the use case is to run a migration before the new version of your application goes live.

  • With self hosting and Docker Compose you can run./run manage migrate before youdocker compose up
  • With Kubernetes, you can use Helm or Argo CD to run it in hook that happens before your main app deployment gets deployed

I never used Railway but I'm guessing they have a way to run any arbitrary commands before or after a release goes out?

I like this strategy because running it in an entrypoint has implications when you want to horizontally scale your app and you have 10 copies of your app all run…

Replies: 1 comment

Comment options

Hi,

I treat migrations as a separate deploy step that's agnostic to how the app is deployed.

Ultimately the use case is to run a migration before the new version of your application goes live.

  • With self hosting and Docker Compose you can run./run manage migrate before youdocker compose up
  • With Kubernetes, you can use Helm or Argo CD to run it in hook that happens before your main app deployment gets deployed

I never used Railway but I'm guessing they have a way to run any arbitrary commands before or after a release goes out?

I like this strategy because running it in an entrypoint has implications when you want to horizontally scale your app and you have 10 copies of your app all running the migrate command. Technically migrations are idempotent but there's still benefits to have an application deployment get blocked from being deployed because a previous unrelated step (running a migration) failed. Separation of concerns.

You must be logged in to vote
0 replies
Answer selected bySHxKM
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@SHxKM@nickjj

[8]ページ先頭

©2009-2025 Movatter.jp