Data Migration with Java
The changelog can be found in
src/main/java/config/migration/MigrationRegistry.java. To create a new change, you have to do the following:
Get the current time in the format
Create a new file in
MigrationEntry<formatted-time>.javacontaining a class extending
Implement the required methods in your class and follow the JavaDoc.
Add the class to the
migrationEntryMapattribute in the
MigrationRegistry.javatogether with the next Integer key inside the constructor.
All executed entries are saved in the table
migration_changelog. If you delete entries, they get executed again.
Test your changes locally first, and only commit changes you are confident that work.
Before deploying any database changes to a test server, ask for official permission from the project lead. If the changes don’t get approved, manual rollbacks can be necessary, which are avoidable.
If queries fail due to the authorization object being null, call SecurityUtils.setAuthorizationObject() beforehand to set a dummy object.