Data Migration with Java
1. Changelog
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
YYYYMMDD_HHmmss
.Create a new file in
/entries
namedMigrationEntry<formatted-time>.java
containing a class extendingMigrationEntry
.Implement the required methods in your class and follow the JavaDoc.
Add the class to the
migrationEntryMap
attribute in theMigrationRegistry.java
together with the next Integer key inside the constructor.
2. Development
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.