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 initializing `DatabaseConnection`s using Flyway.
  Author:
    Matthias Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MigrationService.MigrationStatus` Enum type defining the different states of a database migration.

  - ### Field Summary

    Fields
    Modifier and Type | Field and 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 and Description
    `MigrationService()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected DataSource` | `getDataSource(DatabaseConnection databaseConnection)`
    `protected DataSource` | `getDataSource(String url, String username, String password)`
    `protected org.flywaydb.core.Flyway` | `getFlyway(DatabaseConnection connection, ClassLoader classLoader, String... locations)`
    `DatabaseConnection` | `getPlatformConnection(Properties properties)`
    `protected MigrationService.MigrationStatus` | `initDatabase(DatabaseConnection rootConnection, Boolean doRepair)`
    `DatabaseConnection` | `initDatabase(Properties config)` Configures and (optionally) migrates the appNG root `DatabaseConnection` from the given `Properties`.
    `protected MigrationService.MigrationStatus` | `migrate(org.flywaydb.core.Flyway flyway, DatabaseConnection databaseConnection)`
    `org.flywaydb.core.api.MigrationInfo` | `status(DatabaseConnection connection)` Returns the current `MigrationInfo` for the given `DatabaseConnection`
    `org.flywaydb.core.api.MigrationInfo` | `status(Properties config)` Returns the current `MigrationInfo` for the connection
    `org.flywaydb.core.api.MigrationInfoService` | `statusComplete(DatabaseConnection connection)` Returns the current `MigrationInfoService` for the given `DatabaseConnection` (the appNG root connection).
    `org.flywaydb.core.api.MigrationInfoService` | `statusComplete(DatabaseConnection connection, boolean testConnection)` Returns the current `MigrationInfoService` for the given `DatabaseConnection` (the appNG root connection).
    `org.flywaydb.core.api.MigrationInfoService` | `statusComplete(DatabaseConnection connection, File sqlFolder)` Returns the current `MigrationInfoService` for the given `DatabaseConnection`, which must be owned by a `SiteApplication`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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

  - ### Constructor Detail

    - #### MigrationService

          public MigrationService()

  - ### Method Detail

    - #### initDatabase

          public DatabaseConnection initDatabase(Properties config)

      Configures and (optionally) migrates the appNG root `DatabaseConnection` from the given `Properties`.
      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 current `MigrationInfo` 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 current `MigrationInfo` for the given `DatabaseConnection`
      Parameters:
        `connection` - a `DatabaseConnection`
      Returns:
        the current `MigrationInfo` for the given connection (may be `null`).
      See Also:
        `MigrationInfoService.current()`

    - #### statusComplete

          public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection)

      Returns the current `MigrationInfoService` for the given `DatabaseConnection` (the appNG root connection).
      Parameters:
        `connection` - a `DatabaseConnection`
      Returns:
        the current `MigrationInfoService` for the given connection (may be `null`).
      See Also:
        `MigrationInfoService`

    - #### statusComplete

          public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection,
                                                                           boolean testConnection)

      Returns the current `MigrationInfoService` for the given `DatabaseConnection` (the appNG root connection).
      Parameters:
        `connection` - a `DatabaseConnection`
        `testConnection` - if the connection needs to be tested
      Returns:
        the current `MigrationInfoService` for the given connection (may be `null`).
      See Also:
        `MigrationInfoService`

    - #### statusComplete

          public org.flywaydb.core.api.MigrationInfoService statusComplete(DatabaseConnection connection,
                                                                           File sqlFolder)

      Returns the current `MigrationInfoService` for the given `DatabaseConnection`, which must be owned by a `SiteApplication`.
      Parameters:
        `connection` - a `DatabaseConnection` owned by a `SiteApplication`
        `sqlFolder` - the path to migration scripts
      Returns:
        the current `MigrationInfoService` for the given connection (may be `null`).
      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)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.