Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Makemigrate on startup optional via env variable #82

Open
kevihiiin opened this issue Jul 5, 2020 · 3 comments
Open

Makemigrate on startup optional via env variable #82

kevihiiin opened this issue Jul 5, 2020 · 3 comments

Comments

@kevihiiin
Copy link
Member

Do we want to run migrate every time the container is started?
I know that in our use-case we migrate every time we restart the container because the build changes. But in general it feels wrong to touch the database structure everytime the container is just started even if we don't have to.
A problematic scenario: Say after an unexpected shutdown the database gets corrupted and we now try to re-migrate on startup.

Originally posted by @kevihiiin in #21

@Baschdl
Copy link
Contributor

Baschdl commented Jul 7, 2020

Say after an unexpected shutdown the database gets corrupted

Wouldn't this lead to a postgres startup error?
Are there other scenarios where one doesn't want to migrate?

@kevihiiin
Copy link
Member Author

Wouldn't this lead to a postgres startup error?

In theory it should, but I am certain that errors can occur which are not detected by the integrity check of postgres on startup.

Are there other scenarios where one doesn't want to migrate?

I think the user needs to think the other way round, when do you want to migrate? And make that an explicit action

@maltezacharias suggested that we can add pass a variable which would have to be explicitly set on startup in order to migrate,
probably something like this:
docker-compose up -e MIGRATE_DB=true

This way we can even set it to default in the development environment, but leave it out in production.

@Baschdl
Copy link
Contributor

Baschdl commented Jul 9, 2020

We could also pass something to the entrypoint.sh directly without using environment variables as docker-compose up executes the entrypoint and additional arguments are passed to the entrypoint.sh

This way we can even set it to default in the development environment, but leave it out in production.
We would need to find a solution for this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants