From 5984dbba8055f362bc845d089b4bb916ddce36eb Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 4 Apr 2012 18:46:46 +0000 Subject: [PATCH] Make it possible to register migrations outside a repository. --- .../com/samskivert/depot/DepotRepository.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/samskivert/depot/DepotRepository.java b/src/main/java/com/samskivert/depot/DepotRepository.java index 2593c81..047f435 100644 --- a/src/main/java/com/samskivert/depot/DepotRepository.java +++ b/src/main/java/com/samskivert/depot/DepotRepository.java @@ -709,6 +709,27 @@ public abstract class DepotRepository }); } + /** + * Registers a data migration for this repository. This migration will only be run once and its + * unique identifier will be stored persistently to ensure that it is never run again on the + * same database. Nonetheless, migrations should strive to be idempotent because someone might + * come along and create a brand new system installation and all registered migrations will be + * run once on the freshly created database. As with all database migrations, understand + * clearly how the process works and think about edge cases when creating a migration. + * + *

See {@link PersistenceContext#registerMigration} for details on how schema migrations + * operate and how they might interact with data migrations. + */ + public void registerMigration (DataMigration migration) + { + if (_dataMigs == null) { + // we've already been initialized, so we have to run this migration immediately + runMigration(migration); + } else { + _dataMigs.add(migration); + } + } + /** * Creates a repository with the supplied persistence context. Any schema migrations needed by * this repository should be registered in its constructor. A repository should not @@ -767,27 +788,6 @@ public abstract class DepotRepository _dataMigs = null; // note that we've been initialized } - /** - * Registers a data migration for this repository. This migration will only be run once and its - * unique identifier will be stored persistently to ensure that it is never run again on the - * same database. Nonetheless, migrations should strive to be idempotent because someone might - * come along and create a brand new system installation and all registered migrations will be - * run once on the freshly created database. As with all database migrations, understand - * clearly how the process works and think about edge cases when creating a migration. - * - *

See {@link PersistenceContext#registerMigration} for details on how schema migrations - * operate and how they might interact with data migrations. - */ - protected void registerMigration (DataMigration migration) - { - if (_dataMigs == null) { - // we've already been initialized, so we have to run this migration immediately - runMigration(migration); - } else { - _dataMigs.add(migration); - } - } - /** * Adds the persistent classes used by this repository to the supplied set. */