package io.ebeaninternal.dbmigration.model;
import io.ebeaninternal.dbmigration.migration.Configuration;
import io.ebeaninternal.dbmigration.migration.DefaultTablespace;
Holds configuration such as the default tablespaces to use for tables,
indexes, history tables etc.
/**
* Holds configuration such as the default tablespaces to use for tables,
* indexes, history tables etc.
*/
public class MConfiguration {
Default tablespace for tables.
/**
* Default tablespace for tables.
*/
protected String tableTablespace;
Default tablespace for indexes.
/**
* Default tablespace for indexes.
*/
protected String indexTablespace;
Default tablespace for history tables.
/**
* Default tablespace for history tables.
*/
protected String historyTablespace;
Apply the migration configuration.
It is expected that these are applied in the correct chronological order
from earliest to latest.
/**
* Apply the migration configuration.
* <p>
* It is expected that these are applied in the correct chronological order
* from earliest to latest.
* </p>
*/
public void apply(Configuration configuration) {
DefaultTablespace defaultTablespace = configuration.getDefaultTablespace();
if (defaultTablespace != null) {
String tables = defaultTablespace.getTables();
if (isNotEmpty(tables)) {
this.tableTablespace = tables;
}
String indexes = defaultTablespace.getIndexes();
if (isNotEmpty(indexes)) {
this.indexTablespace = indexes;
}
String history = defaultTablespace.getHistory();
if (isNotEmpty(history)) {
this.historyTablespace = history;
}
}
}
Return the default tablespace to use for tables.
/**
* Return the default tablespace to use for tables.
*/
public String getTableTablespace() {
return tableTablespace;
}
Return the default tablespace to use for indexes.
/**
* Return the default tablespace to use for indexes.
*/
public String getIndexTablespace() {
return indexTablespace;
}
Return the default tablespace to use for history tables.
/**
* Return the default tablespace to use for history tables.
*/
public String getHistoryTablespace() {
return historyTablespace;
}
protected boolean isNotEmpty(String tables) {
return tables != null && !tables.trim().isEmpty();
}
}