Scille / parsec-cloud

Open source Dropbox-like file sharing with full client encryption !
https://parsec.cloud
Other
269 stars 40 forks source link

Check that the migrations have been correctly applied at server startup #8709

Open vxgmichel opened 3 weeks ago

vxgmichel commented 3 weeks ago

We probably should never run a given version of the parsec server when the full list of available migrations have not been applied.

Best case scenario, the server will loudly fail when starting to process new requests. Worst case scenario, we won't know about it until a specific situation occurs. Very worst case scenario, data is updated in a way that makes the tables inconsistent, without explicitly failing

Fixing this can easily be done by checking the migration table and comparing it to the available migrations.

The problem is that scalingo tries to run the freshly deployed app and rolls back to the previous version if it fails.

There are several solutions:

FirelightFlagboy commented 1 week ago

@touilleMan indicated that postdeploy may be a solution for us, we need to investigate if this solution satisfy us.

touilleMan commented 1 week ago

Having a check on the datamodel version at server startup seems a good improvement.

Automatically apply migrations when starting the parsec server (possibly enabled through an dedicated option)

I'm strongly opposed to this given it may lead to migration being applied on the wrong database (e.g. when running a cli command on the wrong database).

We most likely want to rely on postdeploy hook

The trick is postdeploy is done after the new server version is deployed (and shouldn't crash). So in this scenario we cannot do a check on the datamodel version.

So a possibility would be: