How do you deal with migrations practically #1228
-
I am considering using sqlboiler for a new greenfield project having previously used NoSQL. I would like to get a better idea of how people handle migrations in practical production terms. I deploy my applications in K8S with HA, meaning I have at least 3 pods for the application, and it uses rolling deployments (a new pod gets brought up, then once it is ready the old pod is taken down, repeat until all pods are updated). AKA Blue/Green deployment. Now I am trying to reason about how migrations work with Blue/Green deployments and SQLBoiler and am getting a bit stuck. option 1:
However if I do this, while the deployment is ongoing I will cause temporary unexpected behaviour for the pods that are still running the old schema (crashes or invalid data being read/written) due to lack of backwards compatibility. So then there's option 2:
This would ensure consistency but would mean a temporary outage, which is unacceptable. Option 3:
Option 4:
Further questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Option 1, causes unexpected behaviours. Probably safe except if the "unexpected behaviour" would cause huge problems Option 2 requires a bit of downtime. I think this is unavoidable if you're running multiple services on one database and you want to ensure that the version is always correct. Option 3 doesn't seem practical. But for larger backwards-incompatible changes, perhaps something like that is necessary. Option 4 sounds the same as Option 2. I think it makes sense the most. Other questions:
Migration tools tend to have a locking system to prevent issues like this.
SQLBoiler can only be run against a DB. Technically, if you built a driver for DDL statements, then it could work with that too. |
Beta Was this translation helpful? Give feedback.
Option 1, causes unexpected behaviours. Probably safe except if the "unexpected behaviour" would cause huge problems
Option 2 requires a bit of downtime. I think this is unavoidable if you're running multiple services on one database and you want to ensure that the version is always correct.
Option 3 doesn't seem practical. But for larger backwards-incompatible changes, perhaps something like that is necessary.
Option 4 sounds the same as Option 2. I think it makes sense the most.
Other questions: