use of org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo 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.replaceschema.finalinfo.DfAlterCheckFinalInfo in project dbflute-core by dbflute.
the class DfAlterCheckProcess method savePrevious.
// ===================================================================================
// SavePrevious Process
// ====================
public DfAlterCheckFinalInfo savePrevious() {
_log.info("");
_log.info("+-------------------+");
_log.info("| |");
_log.info("| Save Previous |");
_log.info("| |");
_log.info("+-------------------+");
deleteAllNGMark();
final DfAlterCheckFinalInfo finalInfo = new DfAlterCheckFinalInfo();
finalInfo.setResultMessage("{Save Previous}");
if (!checkSavePreviousInvalidStatus(finalInfo)) {
return finalInfo;
}
finishPreviousCheckedAlter();
deleteExtractedPreviousResource();
final List<File> copyToFileList = copyToPreviousResource();
compressPreviousResource();
if (!checkSavedPreviousResource(finalInfo)) {
// failure
return finalInfo;
}
markPreviousOK(copyToFileList);
deleteSavePreviousMark();
finalInfo.addDetailMessage("o (all resources saved)");
return finalInfo;
}
use of org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo 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
replaceSchema(finalInfo);
if (finalInfo.isFailure()) {
return finalInfo;
}
serializeNextSchema();
// to be previous DB
rollbackSchema();
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();
}
deleteSubmittedDraftFile(finalInfo);
// not finally because of trace when abort
deleteSchemaXml();
return finalInfo;
}
use of org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo in project dbflute-core by dbflute.
the class DfSavePreviousProcess method savePrevious.
// ===================================================================================
// SavePrevious Process
// ====================
public DfAlterCheckFinalInfo savePrevious() {
_log.info("");
_log.info("+-------------------+");
_log.info("| |");
_log.info("| Save Previous |");
_log.info("| |");
_log.info("+-------------------+");
deleteAllNGMark();
final DfAlterCheckFinalInfo finalInfo = new DfAlterCheckFinalInfo();
finalInfo.setResultMessage("Save Previous");
if (!checkSavePreviousInvalidStatus(finalInfo)) {
return finalInfo;
}
final long before = System.currentTimeMillis();
_unreleasedAlterAgent.finishReleasedAlterSql();
deleteExtractedPreviousResource();
final List<File> copyToFileList = copyToPreviousResource();
compressPreviousResource();
finalInfo.setResultMessage(finalInfo.getResultMessage() + ": saved=" + copyToFileList.size() + " file(s)");
final long after = System.currentTimeMillis();
// except ReplaceSchema process
finalInfo.setProcessPerformanceMillis(after - before);
if (!checkSavedPreviousResource(finalInfo)) {
// failure
return finalInfo;
}
markPreviousOK(copyToFileList);
deleteSavePreviousMark();
finalInfo.addDetailMessage("o (all resources saved)");
return finalInfo;
}
use of org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo in project dbflute-core by dbflute.
the class DfReplaceSchemaTask method buildReplaceSchemaFinalMessage.
protected String buildReplaceSchemaFinalMessage() {
final StringBuilder sb = new StringBuilder();
if (_cancelled) {
sb.append(" * * * * * * *").append(ln());
sb.append(" * Cancelled *").append(ln());
sb.append(" * * * * * * *");
return sb.toString();
}
// null allowed
final DfReplaceSchemaFinalInfo finalInfo = _replaceSchemaFinalInfo;
boolean firstDone = false;
// AlterFailure
boolean alterFailure = false;
{
final DfAlterCheckFinalInfo alterCheckFinalInfo = _alterCheckFinalInfo;
if (alterCheckFinalInfo != null && alterCheckFinalInfo.isValidInfo()) {
alterFailure = alterCheckFinalInfo.isFailure();
}
}
// CreateSchema
if (finalInfo != null) {
final DfCreateSchemaFinalInfo createSchemaFinalInfo = finalInfo.getCreateSchemaFinalInfo();
if (createSchemaFinalInfo != null && createSchemaFinalInfo.isValidInfo()) {
if (!alterFailure || createSchemaFinalInfo.isFailure()) {
if (firstDone) {
sb.append(ln()).append(ln());
}
firstDone = true;
buildSchemaTaskContents(sb, createSchemaFinalInfo);
}
}
}
// LoadData
if (finalInfo != null) {
final DfLoadDataFinalInfo loadDataFinalInfo = finalInfo.getLoadDataFinalInfo();
if (loadDataFinalInfo != null && loadDataFinalInfo.isValidInfo()) {
if (!alterFailure || loadDataFinalInfo.isFailure()) {
if (firstDone) {
sb.append(ln()).append(ln());
}
firstDone = true;
buildSchemaTaskContents(sb, loadDataFinalInfo);
}
}
}
// TakeFinally
boolean assertionFailure = false;
if (finalInfo != null) {
final DfTakeFinallyFinalInfo takeFinallyFinalInfo = finalInfo.getTakeFinallyFinalInfo();
if (takeFinallyFinalInfo != null) {
assertionFailure = (takeFinallyFinalInfo.getAssertionEx() != null);
if (takeFinallyFinalInfo.isValidInfo()) {
if (!alterFailure || takeFinallyFinalInfo.isFailure()) {
if (firstDone) {
sb.append(ln()).append(ln());
}
firstDone = true;
buildSchemaTaskContents(sb, takeFinallyFinalInfo);
}
}
}
}
// AlterCheck (AlterSchema, SavePrevious)
{
final DfAlterCheckFinalInfo alterCheckFinalInfo = _alterCheckFinalInfo;
if (alterCheckFinalInfo != null && alterCheckFinalInfo.isValidInfo()) {
if (firstDone) {
sb.append(ln()).append(ln());
}
firstDone = true;
buildSchemaTaskContents(sb, alterCheckFinalInfo);
}
}
if (alterFailure) {
// alter or create in AlterCheck
sb.append(ln()).append(" * * * * * * * * * * *");
sb.append(ln()).append(" * Migration Failure *");
sb.append(ln()).append(" * * * * * * * * * * *");
} else if (assertionFailure) {
// assertion in normal time
sb.append(ln()).append(" * * * * * * * * * * *");
sb.append(ln()).append(" * Assertion Failure *");
sb.append(ln()).append(" * * * * * * * * * * *");
} else if (finalInfo != null && finalInfo.hasFailure()) {
// as default
sb.append(ln()).append(" * * * * * *");
sb.append(ln()).append(" * Failure *");
sb.append(ln()).append(" * * * * * *");
}
return sb.toString();
}
Aggregations