-
Notifications
You must be signed in to change notification settings - Fork 15
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
Perform migrations on start up #9
Comments
I worked around this for now by setting the entrypoint to: ["/entry.sh", "sh", "-c", "horizon db migrate up && exec horizon"] |
I'm using an explicit migration job in Kubernetes at the moment but this is not ideal – it's also not consistent with the db initialization. I think making both the db initialization and the migration configurable with an env var makes most sense. @gracenoah What do you think? |
If you want to make the behaviour configurable, then I'm happy with that. Then everyone can do migrations however they want. Running migrations / initialization separately is obviously the right thing to do if you want to enforce least privilege and have a separate database user for the migrations vs running instance, but we've lowered our standards to the lowest common denominator for stellar because of core's behaviour, so at least I'll be running migrations automatically. |
I think it'd also solve the issue you fixed with #11 – if you explicitly tell it to initialize the database and it fails (either because it already exists or because the connection fails) then the container just won't start. Does that make sense? |
I'm not following. Initialization is different from migration. Initialization is always expected to fail on startup except the first time. Migration is always expected to succeed on startup. There are generally 2 desired modes for the management of the db:
We use the former but the latter is also very useful to have for more complex deployments. The split of initialization vs migration is not very useful, but that's just what horizon does, so I'm fine with having 2 flags. |
Stellar core automatically migrates its database on start up if it's not migrated yet and there's no way to control that behaviour. I think that this image should also do the same unconditionally because:
I'd also be happy to have this configurable via an environment variable. Same for core, but it would require a code change for core. See stellar/stellar-core#1912
The text was updated successfully, but these errors were encountered: