Search in sources :

Example 46 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfSequenceExtractorPostgreSQL method buildMetaSelectSql.

protected String buildMetaSelectSql() {
    final String schemaCondition;
    if (!_unifiedSchemaList.isEmpty()) {
        final StringBuilder sb = new StringBuilder();
        for (UnifiedSchema unifiedSchema : _unifiedSchemaList) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append("'").append(unifiedSchema.getPureSchema()).append("'");
        }
        schemaCondition = sb.toString();
    } else {
        schemaCondition = "'public'";
    }
    // and sequences cannot show only connected catalog, maybe...
    return "select * from information_schema.sequences where sequence_schema in (" + schemaCondition + ")";
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 47 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfSequenceExtractorDB2 method buildMetaSelectSql.

protected String buildMetaSelectSql() {
    final String schemaCondition;
    if (!_unifiedSchemaList.isEmpty()) {
        final StringBuilder sb = new StringBuilder();
        for (UnifiedSchema unifiedSchema : _unifiedSchemaList) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append("'").append(unifiedSchema.getPureSchema()).append("'");
        }
        schemaCondition = sb.toString();
    } else {
        return null;
    }
    // the table 'SEQUENCES' on DB2 does not have catalog of sequence
    return "select * from SYSCAT.SEQUENCES where SEQSCHEMA in (" + schemaCondition + ")";
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 48 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfCreateSchemaProcess method initializeSchemaAdditionalDrop.

protected boolean initializeSchemaAdditionalDrop() {
    final List<Map<String, Object>> additionalDropMapList = getReplaceSchemaProperties().getAdditionalDropMapList();
    if (additionalDropMapList.isEmpty()) {
        return false;
    }
    _log.info("");
    _log.info("* * * * * * * * * * * * * * * * * * * *");
    _log.info("*                                     *");
    _log.info("* Initialize Schema (Additional Drop) *");
    _log.info("*                                     *");
    _log.info("* * * * * * * * * * * * * * * * * * * *");
    if (_lazyConnection) {
        _log.info("*Passed because it's a lazy connection");
        return false;
    }
    boolean initialized = false;
    for (Map<String, Object> additionalDropMap : additionalDropMapList) {
        final UnifiedSchema dropSchema = getReplaceSchemaProperties().getAdditionalDropSchema(additionalDropMap);
        final String dropUrl = getReplaceSchemaProperties().getAdditionalDropUrl(additionalDropMap);
        final StringBuilder logSb = new StringBuilder();
        if (dropSchema.hasSchema()) {
            logSb.append("[").append(dropSchema.getLoggingSchema()).append("]");
            if (dropUrl != null && dropUrl.trim().length() > 0) {
                logSb.append(": ").append(dropUrl);
            }
        } else {
            if (dropUrl != null && dropUrl.trim().length() > 0) {
                logSb.append(dropUrl);
            }
        }
        _log.info(logSb.toString());
        final DfSchemaInitializer initializer = createSchemaInitializerAdditional(additionalDropMap);
        if (initializer != null) {
            initializer.initializeSchema();
            initialized = true;
        }
    }
    return initialized;
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) DfSchemaInitializer(org.dbflute.logic.replaceschema.schemainitializer.DfSchemaInitializer)

Example 49 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfTakeFinallyProcess method createAsTakeAssert.

public static DfTakeFinallyProcess createAsTakeAssert(String sqlRootDir, DataSource dataSource) {
    final UnifiedSchema mainSchema = getDatabaseProperties().getDatabaseSchema();
    final DfTakeFinallyProcess process = new DfTakeFinallyProcess(sqlRootDir, dataSource, mainSchema, null, null);
    return // take-assert is not only for test data (if needs, option?)
    process.suppressConventionalTakeAssert().suppressSequenceIncrement().skipIfNonAssetionSql().rollbackTransaction().continueIfAssetionFailure();
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 50 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfTakeFinallyProcess method createAsAlterSchema.

public static DfTakeFinallyProcess createAsAlterSchema(final String sqlRootDir, DataSource dataSource) {
    final UnifiedSchema mainSchema = getDatabaseProperties().getDatabaseSchema();
    final DfTakeFinallySqlFileProvider provider = new DfTakeFinallySqlFileProvider() {

        public List<File> provide() {
            return getReplaceSchemaProperties().getMigrationAlterTakeFinallySqlFileList(sqlRootDir);
        }
    };
    final DfTakeFinallyProcess process = new DfTakeFinallyProcess(sqlRootDir, dataSource, mainSchema, provider, null);
    // but increment sequences for development after AlterCheck
    return process.suppressConventionalTakeAssert().restrictIfNonAssetionSql().rollbackTransaction();
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) File(java.io.File)

Aggregations

UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)63 Map (java.util.Map)9 StringKeyMap (org.dbflute.helper.StringKeyMap)9 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)8 LinkedHashMap (java.util.LinkedHashMap)7 ResultSet (java.sql.ResultSet)6 DfSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta)6 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)6 ArrayList (java.util.ArrayList)5 LinkedHashSet (java.util.LinkedHashSet)4 DfProcedureSupplementExtractor (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureSupplementExtractor)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 TypeMap (org.apache.torque.engine.database.model.TypeMap)3 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)3 DfAdditionalSchemaInfo (org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo)3 Connection (java.sql.Connection)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2