How do you guys run `prisma migrate deploy` in you...
# orm-help
b
How do you guys run
prisma migrate deploy
in your kubernetes environments? I'm currently thinking
init containers
might be the way to go - does it hurt to run
prisma migrate deploy
whenever a pod is rescheduled?
r
@Benjamin Kroeger 👋
migrate deploy
is idempotent so it wouldn’t hurt running on a pod reschedule.
👍 1
I have seen some also run
migrate deploy
in commands too so that’s also an option.
b
is there a best-practices guide on prisma2 with kubernetes already?
r
Not yet unfortunately. But it should be similar to other ORM’s out there that support migrations. For e.g. in Django or Rails
b
ok, cool. I'll go ahead with the
init containers
approach and double-check on recommendations for Django
💯 1
thanks
🙌 1
p
we are using helm for our kubernetes deployments so we use a job that is triggered by helms
post-install
and
pre-upgrade
hooks
👍 1
@Benjamin Kroeger this may not apply to you, but we were using init containers and switched to the job because we ran into issues when we added replicas to our api pod for scaling because sometimes multiple replicas would init at the same time and the migrate commands would fight and one would explode. That was about a year ago though so ymmv now, a lot has changed with
migrate
since then!
b
thanks @Patrick Ayres. That sounds like a good use of helm. So far we got away with kustomize pretty well. so I'll double-check on weather jobs work there as well. afaik migrate uses some sort of atomic locking. Maybe @Ryan can confirm that?!
r
Migrate uses transactions so I don’t think that it should conflict with one another.