Search in sources :

Example 6 with DfSchemaDiff

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
    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;
}
Also used : DfSchemaDiff(org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff) DfAlterCheckFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo)

Example 7 with DfSchemaDiff

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();
    schemaDiff.loadNextSchema();
    schemaDiff.analyzeDiff();
    return schemaDiff;
}
Also used : DfSchemaDiff(org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff)

Example 8 with DfSchemaDiff

use of org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff in project dbflute-core by dbflute.

the class DfFirstDateAgent method getTableFirstDateMap.

protected Map<String, Date> getTableFirstDateMap() {
    // case insensitive (not flexible because of historical changes)
    if (_tableFirstDateMap != null) {
        return _tableFirstDateMap;
    }
    final Map<String, Date> tableFirstDateMap = StringKeyMap.createAsCaseInsensitiveOrdered();
    final List<DfSchemaDiff> schemaDiffList = prepareSchemaDiffList();
    for (DfSchemaDiff schemaDiff : schemaDiffList) {
        List<DfTableDiff> tableDiffList = schemaDiff.getAddedTableDiffList();
        for (DfTableDiff tableDiff : tableDiffList) {
            final String tableName = tableDiff.getTableName();
            tableFirstDateMap.put(tableName, schemaDiff.getNativeDiffDate());
        }
    }
    _tableFirstDateMap = tableFirstDateMap;
    return _tableFirstDateMap;
}
Also used : DfSchemaDiff(org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff) DfTableDiff(org.dbflute.logic.jdbc.schemadiff.DfTableDiff) Date(java.util.Date) HandyDate(org.dbflute.helper.HandyDate)

Aggregations

DfSchemaDiff (org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff)8 Date (java.util.Date)2 HandyDate (org.dbflute.helper.HandyDate)2 DfTableDiff (org.dbflute.logic.jdbc.schemadiff.DfTableDiff)2 DfAlterCheckFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 DfColumnDiff (org.dbflute.logic.jdbc.schemadiff.DfColumnDiff)1 DfSchemaXmlSerializer (org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer)1