use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.
the class DfAlterCheckProcess method checkAlter.
// ===================================================================================
// AlterCheck Process
// ==================
public DfAlterCheckFinalInfo checkAlter() {
deleteAllNGMark();
deleteSchemaXml();
deleteCraftMeta();
final DfAlterCheckFinalInfo finalInfo = new DfAlterCheckFinalInfo();
// after AlterCheck, the database has altered schema
// so you can check your application on the environment
// to be next DB
becomeNextSchema(finalInfo);
if (finalInfo.isFailure()) {
return finalInfo;
}
serializeNextSchema();
// to be previous DB
becomePreviousSchema();
alterSchema(finalInfo);
if (finalInfo.isFailure()) {
return finalInfo;
}
serializePreviousSchema();
// to replace the result file
deleteAlterCheckResultDiff();
final DfSchemaDiff schemaDiff = schemaDiff();
if (schemaDiff.hasDiff()) {
processDifference(finalInfo, schemaDiff);
} else {
processSuccess(finalInfo);
deleteAlterCheckMark();
deleteCraftMeta();
}
// not finally because of trace when abort
deleteSchemaXml();
return finalInfo;
}
use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.
the class DfAlterCheckProcess method schemaDiff.
// ===================================================================================
// SchemaDiff
// ==========
protected DfSchemaDiff schemaDiff() {
_log.info("");
_log.info("+-----------------+");
_log.info("| |");
_log.info("| Schema Diff |");
_log.info("| |");
_log.info("+-----------------|");
final String previousXml = getMigrationAlterCheckPreviousSchemaXml();
final String nextXml = getMigrationAlterCheckNextSchemaXml();
final DfSchemaDiff schemaDiff = DfSchemaDiff.createAsAlterCheck(previousXml, nextXml);
schemaDiff.enableCraftDiff(getMigrationAlterCheckCraftMetaDir());
schemaDiff.loadPreviousSchema();
// always can read here so no check
schemaDiff.loadNextSchema();
schemaDiff.analyzeDiff();
return schemaDiff;
}
use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.
the class DfFirstDateAgent method getColumnFirstDateMap.
protected Map<String, Date> getColumnFirstDateMap() {
// case insensitive (not flexible because of historical changes)
if (_columnFirstDateMap != null) {
return _columnFirstDateMap;
}
final Map<String, Date> columnFirstDateMap = StringKeyMap.createAsCaseInsensitiveOrdered();
final List<DfSchemaDiff> schemaDiffList = prepareSchemaDiffList();
for (DfSchemaDiff schemaDiff : schemaDiffList) {
final List<DfTableDiff> tableDiffList = schemaDiff.getChangedTableDiffList();
for (DfTableDiff tableDiff : tableDiffList) {
final String tableName = tableDiff.getTableName();
final List<DfColumnDiff> columnDiffList = tableDiff.getAddedColumnDiffList();
for (DfColumnDiff columnDiff : columnDiffList) {
final String columnName = columnDiff.getColumnName();
final String keyName = generateColumnKey(tableName, columnName);
columnFirstDateMap.put(keyName, schemaDiff.getNativeDiffDate());
}
}
}
_columnFirstDateMap = columnFirstDateMap;
return _columnFirstDateMap;
}
use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.
the class DfSchemaSyncChecker method checkSync.
// ===================================================================================
// Check Sync
// ==========
public void checkSync() {
clearOutputResource();
final DfSchemaXmlSerializer serializer = diffSchema();
_log.info("");
_log.info("* * * * * * * * * * * * * * * * *");
_log.info("* *");
_log.info("* Check Schema Synchronized *");
_log.info("* *");
_log.info("* * * * * * * * * * * * * * * * *");
final DfSchemaDiff schemaDiff = serializer.getSchemaDiff();
if (schemaDiff.hasDiff()) {
_log.info(" -> the schema has differences");
throwSchemaSyncCheckTragedyResultException();
} else {
// synchronized
_log.info(" -> the schema is synchronized");
clearOutputResource();
}
}
use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.
the class DfSchemaHistory method acceptDiffMap.
protected void acceptDiffMap(Map<String, Object> diffMap) {
final Set<Entry<String, Object>> entrySet = diffMap.entrySet();
int index = 0;
for (Entry<String, Object> entry : entrySet) {
// diffDate
final String key = entry.getKey();
final Object value = entry.getValue();
assertDiffElementMap(key, value);
@SuppressWarnings("unchecked") final Map<String, Object> schemaDiffMap = (Map<String, Object>) value;
final DfSchemaDiff schemaDiff = DfSchemaDiff.createAsHistory();
schemaDiff.acceptSchemaDiffMap(schemaDiffMap);
if (index == 0) {
schemaDiff.setLatest(true);
}
_schemaDiffList.add(schemaDiff);
++index;
}
}
Aggregations