enhancement
major
minor
major
minor
major
#29979
Migration: migrations of an application module without a stored version never run, the auto model upgrade runs instead
Observed with 8.0.0-alpha11 in E-Home (haumacher/ehome, migration Ticket_29806_Dissolve_ehome_mask).
An application that had no migration of its own so far adds its first migration module (ehome, a migration config in autoconf plus WEB-INF/kbase/migration/ehome/*.migration.xml). On the first start against an existing database the migration service reports "No migration required" and skips it, because the module has no stored version in the database. The automatic model upgrade then applies the model change itself - here destructively: it deleted the old module ehome.mask and created a new empty singleton, so the singleton's 34 objects were lost.
Workaround: minimum-modules="ehome" in the migration configuration.
Expected: a migration module without a stored version runs its migrations (or the documentation of "Own migrations" in the upgrade guide says that minimum-modules is needed for the first migration of an application).
Lösung
A migration module without a stored data version is treated as a module that is new to the application (e.g. a framework module added as dependency): its data does not exist yet, so its migrations are skipped. This is the correct behavior for an added dependency, but the database cannot distinguish it from an application module whose database was created before the module had a migration folder. Therefore:
- Versions are stored on every startup. The maximal version of every configured migration module without a stored version is written to the database also when no migration runs (before, versions were written only at database setup and after a migration run). A module without a stored version is thus reliably a module added since the last start.
- Skipped migrations are logged. Instead of the plain "No migration required", the migration service logs (info) every module whose migrations are skipped because it has no stored version, together with the remedy minimum-modules="<module>" for the case that the module's data already exists.
- Documentation. The upgrade guide ("Own migrations") and the JavaDoc of minimum-modules describe that the first migration of an application whose database was created without the application's migration folder needs minimum-modules="<app module>".