vendredi 24 juin 2016

MySQL check if table has correct schema

I am currently developing server software in C++ with a MySQL data backend. I am using the offical MySQL/connector library from Oracle to work with MySQL. The connection itself is working and I'm not having any issues with that.
My problem is that the database and the table schemas tend to change every once in a while because new tables and columns keep getting added. Also exiting column may be changed for the same reason. To make sure I recognize outdated server software quickly I wanted to add a warning when the database has changed.
My first idea was to hardcode how the database (and tables and such) should look and then check whether the current database matches the hardcoded data. But I have no clue how to achive that.

In summary I want to be able to detect whether

  • A table has been added or removed
  • A column in a table has been altered
  • A column in a table has been added or removed

with as little C++ code as possible. Also it should be quite easy to maintain.

Additional information will be added when required.

Aucun commentaire:

Enregistrer un commentaire