-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from FOCONIS/migration-context
Introduce MigrationContext to be prepared for JDBC migration refactor
- Loading branch information
Showing
11 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.ebean.migration; | ||
|
||
import java.sql.Connection; | ||
|
||
/** | ||
* The current context while a migration runs. | ||
* <p> | ||
* This is used to provide meta-informations in JDBC migrations and mainly provides a read-only access | ||
* to a subset of MigrationConfig. | ||
* <p> | ||
* It is possible to provide an extended implementation in <code>MigrationEngine.run(context)</code>, | ||
* which is accessible in JdbcMigration. So you can create a EbeanMigrationContext, so that you can | ||
* access the current ebean server in the JDBC migration. | ||
* | ||
* @author Roland Praml, FOCONIS AG | ||
*/ | ||
public interface MigrationContext { | ||
/** | ||
* The current connection. Note: During migration, this connection is always the same. | ||
* You must not close this connection! | ||
*/ | ||
Connection connection(); | ||
|
||
/** | ||
* The migration path of SQL migrations. You can use this, to load additional SQL resources | ||
* in your JDBC migration or determine, if this JDBC migration is for a particular path. | ||
* This can be used if you have multiple ebean servers for different databases. | ||
*/ | ||
String migrationPath(); | ||
|
||
/** | ||
* The platform of the current migration run. (e.g. <code>sqlserver17</code>) | ||
*/ | ||
String platform(); | ||
|
||
/** | ||
* The base platform of the current migration run. (e.g. <code>sqlserver</code>) | ||
*/ | ||
String basePlatform(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.ebean.migration.runner; | ||
|
||
import io.ebean.migration.MigrationConfig; | ||
import io.ebean.migration.MigrationContext; | ||
|
||
import java.sql.Connection; | ||
|
||
/** | ||
* A default implementation of the MigrationContext. | ||
* | ||
* @author Roland Praml, FOCONIS AG | ||
*/ | ||
public class DefaultMigrationContext implements MigrationContext { | ||
private final Connection connection; | ||
private final String migrationPath; | ||
private final String platform; | ||
private final String basePlatform; | ||
|
||
public DefaultMigrationContext(MigrationConfig config, Connection connection) { | ||
this.connection = connection; | ||
this.migrationPath = config.getMigrationPath(); | ||
this.platform = config.getPlatform(); | ||
this.basePlatform = config.getBasePlatform(); | ||
} | ||
|
||
@Override | ||
public Connection connection() { | ||
return connection; | ||
} | ||
|
||
@Override | ||
public String migrationPath() { | ||
return migrationPath; | ||
} | ||
|
||
@Override | ||
public String platform() { | ||
return platform; | ||
} | ||
|
||
@Override | ||
public String basePlatform() { | ||
return basePlatform; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.