Closed quintesse closed 9 years ago
@FroMage This is now done. There's also a simple script in the root of the project query-db-version.sh
that will tell you the current version of your database and a README explaining what to do when making changes to the database. The most important part of which is:
Also, from version 19 onwards you MUST not forget to update the same version number in the first line of the
db-XX.sql
file, while allupdate-XX.sql
files MUST include the following SQL command:UPDATE herd_metainf SET value = 'XX' WHERE key = 'db_schema_version';
Where
XX
should of course be replaced by the new version number (the same as theXX
in the name of theupdate-XX.sql
file itself).
Except you're missing the Hibernate mapping. In DEV mode it's Hibernate which creates the DB.
Ok, I didn't know that
Is defining the entity as I just did enough?
Ah no, of course not. I still have to add that version entry somehow.
Right. I suppose you can do it in Bootstrap
but ONLY in DEV mode ;) Play.mode
will tell you IIRC.
Well I could probably just check if the key exists and if not add it with the correct number, right?
Well that would also set it up on PROD if the user forgot to initialise his DB, which would be confusing because at this point it should be empty.
Ok, understood.
Done.
This is useful to know at which version you're current DB is and which upgrade scripts have to be run to get to the latest version.
Probably should just add a simple key-value table called
herd_metainf
for example. And then have a key calleddb_schema_version
.