0

So I have this debian package that install some nodejs application web app which uses a mysql database. The package have a postinst script that run the db migrate command bundled with he package.

Now, I want to shard the application into multiple server (2 frontend and 1 database backend). The problem I am facing is that both frontend servers are going to try to update the schema at the same when deploying the new packages. This does not seems right to me.

Also, it kind of create a dependency between the package and a running mysql server. This does not seems right to me either.

What are the good ways of acheiving automatic database schema upgrade when a new package requires it ?

Nico
  • 429
  • 5
  • 12

1 Answers1

1

Either the package should automatically upgrade the DB schema, or it should come with instructions on how to do it manually and state clearly that this is a required step.

If it goes for the auto-upgrade way, then it should check whether the schema has already been upgraded; and if it's supposed to be installed on multiple servers sharing a single DB, it should also either use some form of locking, or explicitly tell you "please don't upgrade this package on all servers at the same time".

TL;DR: your package seems to suffer from lazy programming and/or lazy documentation.

Massimo
  • 70,200
  • 57
  • 200
  • 323
  • Do you consider an acceptable practice for a package to auto-upgrade the database on installation ? What should the package do ? – Nico Jun 15 '16 at 21:02
  • It depends on how the package is meant to be used, on how it's developed and on how it's documented. If the upgrade path is clear and reliable, then yes, it's acceptable. But if it leaves you wondering "what's going to happen here, will this upgrade destroy my application?" then something is clearly missing. – Massimo Jun 15 '16 at 21:11
  • Example: Lync (a Microsoft product) employs multiple front-end servers sharing the same back-end database; upgrades usually require DB changes, but they are not automated; each upgrade package includes a script for upgrading the DB, and the documentation *clearly states that you MUST manually run it*. Also, the script is built so that if you run it multiple times, it just does nothing because it detects the DB upgrade has already been done. No ambiguity and no risk anywhere. Unless you forget to read the docs, but then it's YOUR problem, not theirs. – Massimo Jun 15 '16 at 21:16