parent
d0d79ccc95
commit
5bc2137193
|
|
@ -24,7 +24,7 @@ wildfly please refer to the WildFly documentation
|
||||||
following content:
|
following content:
|
||||||
|
|
||||||
```
|
```
|
||||||
?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
|
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
|
||||||
<resources>
|
<resources>
|
||||||
<resource-root path="postgresql-42.2.10.jar"/>
|
<resource-root path="postgresql-42.2.10.jar"/>
|
||||||
|
|
@ -64,7 +64,7 @@ wildfly please refer to the WildFly documentation
|
||||||
1. Start the JBOSS CLI tool: `bin/jboss-cli.sh` or `bin/jboss-cli.bat`.
|
1. Start the JBOSS CLI tool: `bin/jboss-cli.sh` or `bin/jboss-cli.bat`.
|
||||||
2. Add new datasource:
|
2. Add new datasource:
|
||||||
```
|
```
|
||||||
[standalone@localhost:9990 /] data-source add --name=scicms-devel --driver-name=postgresql --jndi-name=java:/comp/env/jdbc/scientificcms/db --connection-url=jdbc:postgresql://localhost:5432/scicms-devel --user-name=libreccm --password=libreccm
|
[standalone@localhost:9990 /] data-source add --name=librecms --driver-name=postgresql --jndi-name=java:/comp/env/jdbc/scientificcms/db --connection-url=jdbc:postgresql://localhost:5432/librecm --user-name=libreccm --password=libreccm
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace the name of the datasource, the connection URL,
|
Replace the name of the datasource, the connection URL,
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,15 @@ public class CcmIntegrator implements Integrator {
|
||||||
|
|
||||||
//Migrate tables and sequences which don't belong to a module
|
//Migrate tables and sequences which don't belong to a module
|
||||||
//for instance the hibernate_sequence
|
//for instance the hibernate_sequence
|
||||||
final Flyway flyway = new Flyway();
|
|
||||||
flyway.setDataSource(dataSource);
|
|
||||||
final StringBuffer buffer = new StringBuffer(
|
final StringBuffer buffer = new StringBuffer(
|
||||||
"db/migrations/org/libreccm/base");
|
"db/migrations/org/libreccm/base");
|
||||||
appendDbLocation(buffer, connection);
|
appendDbLocation(buffer, connection);
|
||||||
flyway.setLocations(buffer.toString());
|
final Flyway flyway = Flyway
|
||||||
|
.configure()
|
||||||
|
.dataSource(dataSource)
|
||||||
|
.locations(buffer.toString())
|
||||||
|
.load();
|
||||||
|
|
||||||
flyway.migrate();
|
flyway.migrate();
|
||||||
|
|
||||||
//Migrate the modules
|
//Migrate the modules
|
||||||
|
|
@ -267,17 +270,18 @@ public class CcmIntegrator implements Integrator {
|
||||||
moduleInfo.load(module);
|
moduleInfo.load(module);
|
||||||
|
|
||||||
//Create a Flyway instance for the the module.
|
//Create a Flyway instance for the the module.
|
||||||
final Flyway flyway = new Flyway();
|
final String schema;
|
||||||
flyway.setDataSource(dataSource);
|
|
||||||
//Set schema correctly for the different databases. Necessary because
|
|
||||||
//different RDBMS handle case different.
|
|
||||||
if ("H2".equals(connection.getMetaData().getDatabaseProductName())) {
|
if ("H2".equals(connection.getMetaData().getDatabaseProductName())) {
|
||||||
flyway.setSchemas(getSchemaName(moduleInfo).toUpperCase(
|
schema = getSchemaName(moduleInfo).toUpperCase(Locale.ROOT);
|
||||||
Locale.ROOT));
|
|
||||||
} else {
|
} else {
|
||||||
flyway.setSchemas(getSchemaName(moduleInfo));
|
schema = getSchemaName(moduleInfo);
|
||||||
}
|
}
|
||||||
flyway.setLocations(getLocation(moduleInfo, connection));
|
final Flyway flyway = Flyway
|
||||||
|
.configure()
|
||||||
|
.dataSource(dataSource)
|
||||||
|
.schemas(schema)
|
||||||
|
.locations(getLocation(moduleInfo, connection))
|
||||||
|
.load();
|
||||||
|
|
||||||
//Get current migrations info
|
//Get current migrations info
|
||||||
final MigrationInfo current = flyway.info().current();
|
final MigrationInfo current = flyway.info().current();
|
||||||
|
|
@ -394,10 +398,12 @@ public class CcmIntegrator implements Integrator {
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
LOGGER.info("Removing schema for module %s...",
|
LOGGER.info("Removing schema for module %s...",
|
||||||
module.getClass().getName());
|
module.getClass().getName());
|
||||||
final Flyway flyway = new Flyway();
|
final Flyway flyway = Flyway
|
||||||
flyway.setDataSource(dataSource);
|
.configure()
|
||||||
flyway.setSchemas(getSchemaName(moduleInfo));
|
.dataSource(dataSource)
|
||||||
flyway.setLocations(getLocation(moduleInfo, connection));
|
.schemas(getSchemaName(moduleInfo))
|
||||||
|
.locations(getLocation(moduleInfo, connection))
|
||||||
|
.load();
|
||||||
LOGGER.warn("Deleting schema for module {}...",
|
LOGGER.warn("Deleting schema for module {}...",
|
||||||
moduleInfo.getModuleName());
|
moduleInfo.getModuleName());
|
||||||
flyway.clean();
|
flyway.clean();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue