Package org.appng.core.service
Class MigrationService
- java.lang.Object
-
- org.appng.core.service.MigrationService
-
- Direct Known Subclasses:
DatabaseService
public class MigrationService extends Object
A service offering methods for configuring and initializingDatabaseConnection
s using Flyway.- Author:
- Matthias Müller
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MigrationService.MigrationStatus
Enum type defining the different states of a database migration.
-
Field Summary
Fields Modifier and Type Field Description protected static String
APP_NG_ROOT_DATABASE
static String
DATABASE_MAX_CONNECTIONS
static String
DATABASE_MIN_CONNECTIONS
static String
DATABASE_NAME
protected static String
DATABASE_NAME_PREFIX
static String
DATABASE_REPAIR
static String
DATABASE_TYPE
protected static String
DATABASE_VALIDATION_PERIOD
protected static String
DATABASE_VALIDATION_QUERY
protected static String
HIBERNATE_CONNECTION_DRIVER_CLASS
protected static String
HIBERNATE_CONNECTION_PASSWORD
protected static String
HIBERNATE_CONNECTION_URL
protected static String
HIBERNATE_CONNECTION_USERNAME
-
Constructor Summary
Constructors Constructor Description MigrationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DataSource
getDataSource(String url, String username, String password)
protected DataSource
getDataSource(DatabaseConnection databaseConnection)
protected org.flywaydb.core.Flyway
getFlyway(DatabaseConnection connection, ClassLoader classLoader, String... locations)
DatabaseConnection
getPlatformConnection(Properties properties)
DatabaseConnection
initDatabase(Properties config)
Configures and (optionally) migrates the appNG rootDatabaseConnection
from the givenProperties
.protected MigrationService.MigrationStatus
initDatabase(DatabaseConnection rootConnection, Boolean doRepair)
protected MigrationService.MigrationStatus
migrate(org.flywaydb.core.Flyway flyway, DatabaseConnection databaseConnection)
org.flywaydb.core.api.MigrationInfo
status(Properties config)
Returns the currentMigrationInfo
for the connectionorg.flywaydb.core.api.MigrationInfo
status(DatabaseConnection connection)
Returns the currentMigrationInfo
for the givenDatabaseConnection
org.flywaydb.core.api.MigrationInfoService
statusComplete(DatabaseConnection connection)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
(the appNG root connection).org.flywaydb.core.api.MigrationInfoService
statusComplete(DatabaseConnection connection, boolean testConnection)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
(the appNG root connection).org.flywaydb.core.api.MigrationInfoService
statusComplete(DatabaseConnection connection, File sqlFolder)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
, which must be owned by aSiteApplication
.
-
-
-
Field Detail
-
DATABASE_MIN_CONNECTIONS
public static final String DATABASE_MIN_CONNECTIONS
- See Also:
- Constant Field Values
-
DATABASE_MAX_CONNECTIONS
public static final String DATABASE_MAX_CONNECTIONS
- See Also:
- Constant Field Values
-
DATABASE_NAME
public static final String DATABASE_NAME
- See Also:
- Constant Field Values
-
DATABASE_REPAIR
public static final String DATABASE_REPAIR
- See Also:
- Constant Field Values
-
DATABASE_TYPE
public static final String DATABASE_TYPE
- See Also:
- Constant Field Values
-
DATABASE_VALIDATION_QUERY
protected static final String DATABASE_VALIDATION_QUERY
- See Also:
- Constant Field Values
-
DATABASE_VALIDATION_PERIOD
protected static final String DATABASE_VALIDATION_PERIOD
- See Also:
- Constant Field Values
-
HIBERNATE_CONNECTION_PASSWORD
protected static final String HIBERNATE_CONNECTION_PASSWORD
- See Also:
- Constant Field Values
-
HIBERNATE_CONNECTION_USERNAME
protected static final String HIBERNATE_CONNECTION_USERNAME
- See Also:
- Constant Field Values
-
HIBERNATE_CONNECTION_DRIVER_CLASS
protected static final String HIBERNATE_CONNECTION_DRIVER_CLASS
- See Also:
- Constant Field Values
-
HIBERNATE_CONNECTION_URL
protected static final String HIBERNATE_CONNECTION_URL
- See Also:
- Constant Field Values
-
APP_NG_ROOT_DATABASE
protected static final String APP_NG_ROOT_DATABASE
- See Also:
- Constant Field Values
-
DATABASE_NAME_PREFIX
protected static final String DATABASE_NAME_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
initDatabase
public DatabaseConnection initDatabase(Properties config)
Configures and (optionally) migrates the appNG rootDatabaseConnection
from the givenProperties
.- Parameters:
config
- the properties read from "/conf/appNG.properties"- Returns:
- the appNG root
DatabaseConnection
-
getPlatformConnection
public DatabaseConnection getPlatformConnection(Properties properties)
-
status
public org.flywaydb.core.api.MigrationInfo status(Properties config)
Returns the currentMigrationInfo
for the connection- Parameters:
config
- the configuration read from "/conf/appNG.properties"- Returns:
- the current
MigrationInfo
for the given connection - See Also:
status(DatabaseConnection)
-
status
public org.flywaydb.core.api.MigrationInfo status(DatabaseConnection connection)
Returns the currentMigrationInfo
for the givenDatabaseConnection
- Parameters:
connection
- aDatabaseConnection
- Returns:
- the current
MigrationInfo
for the given connection (may benull
). - See Also:
MigrationInfoService.current()
-
statusComplete
public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
(the appNG root connection).- Parameters:
connection
- aDatabaseConnection
- Returns:
- the current
MigrationInfoService
for the given connection (may benull
). - See Also:
MigrationInfoService
-
statusComplete
public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection, boolean testConnection)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
(the appNG root connection).- Parameters:
connection
- aDatabaseConnection
testConnection
- if the connection needs to be tested- Returns:
- the current
MigrationInfoService
for the given connection (may benull
). - See Also:
MigrationInfoService
-
statusComplete
public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection, File sqlFolder)
Returns the currentMigrationInfoService
for the givenDatabaseConnection
, which must be owned by aSiteApplication
.- Parameters:
connection
- aDatabaseConnection
owned by aSiteApplication
sqlFolder
- the path to migration scripts- Returns:
- the current
MigrationInfoService
for the given connection (may benull
). - See Also:
MigrationInfoService
-
getFlyway
protected org.flywaydb.core.Flyway getFlyway(DatabaseConnection connection, ClassLoader classLoader, String... locations)
-
initDatabase
protected MigrationService.MigrationStatus initDatabase(DatabaseConnection rootConnection, Boolean doRepair)
-
migrate
protected MigrationService.MigrationStatus migrate(org.flywaydb.core.Flyway flyway, DatabaseConnection databaseConnection)
-
getDataSource
protected DataSource getDataSource(DatabaseConnection databaseConnection)
-
getDataSource
protected DataSource getDataSource(String url, String username, String password)
-
-