eclipse-archived / ceylon-herd

The Ceylon repository web application
Apache License 2.0
21 stars 11 forks source link

Add DB schema version number somewhere #226

Closed quintesse closed 9 years ago

quintesse commented 9 years ago

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 called db_schema_version.

quintesse commented 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.sqlfile, while all update-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 the XX in the name of the update-XX.sql file itself).

FroMage commented 9 years ago

Except you're missing the Hibernate mapping. In DEV mode it's Hibernate which creates the DB.

quintesse commented 9 years ago

Ok, I didn't know that

quintesse commented 9 years ago

Is defining the entity as I just did enough?

quintesse commented 9 years ago

Ah no, of course not. I still have to add that version entry somehow.

FroMage commented 9 years ago

Right. I suppose you can do it in Bootstrap but ONLY in DEV mode ;) Play.mode will tell you IIRC.

quintesse commented 9 years ago

Well I could probably just check if the key exists and if not add it with the correct number, right?

FroMage commented 9 years ago

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.

quintesse commented 9 years ago

Ok, understood.

quintesse commented 9 years ago

Done.