View Issue Details

IDProjectCategoryView StatusLast Update
0001153SymmetricDSBugpublic2013-04-26 13:11
ReporterborballAssigned To 
Prioritynormal 
Status newResolutionopen 
Product Version3.3.4 
Target VersionFixed in Version 
Summary0001153: Drop tables in Database failed
DescriptionCan not drop tables when call API: public void alterDatabase(Database desiredDatabase, boolean continueOnError) in org.jumpmind.db.platform.IDatabasePlatform
Steps To Reproduce1. create one table in datasource with IDatabasePlatform.createTables()
2. drop the table with :
        Database oldDatabase = readDatabase(dataSource);
        for (Table table : tables) {
            oldDatabase.removeTable(table);
        }
        getDatabasePlatform(dataSource).alterDatabase(oldDatabase, false);
3. The table is still there.
Additional InformationPotension issues in Code: org.jumpmind.db.platform.AbstractDatabasePlatform
public void alterTables(boolean continueOnError, Table... desiredTables) {
        Database currentDatabase = new Database();
        Database desiredDatabase = new Database();
        StringBuilder tablesProcessed = new StringBuilder();
        for (Table table : desiredTables) {
            tablesProcessed.append(table.getFullyQualifiedTableName());
            tablesProcessed.append(", ");
            desiredDatabase.addTable(table);
            Table currentTable = ddlReader.readTable(table.getCatalog(), table.getSchema(),
                    table.getName());
            if (currentTable != null) {
                currentDatabase.addTable(currentTable);
            }
        }

        if (tablesProcessed.length() > 1) {
            tablesProcessed.replace(tablesProcessed.length() - 2, tablesProcessed.length(), "");
        }

        String alterSql = ddlBuilder.alterDatabase(currentDatabase, desiredDatabase);

        if (StringUtils.isNotBlank(alterSql.trim())) {
            log.info("Running alter sql:\n{}", alterSql);
            String delimiter = getDdlBuilder().getDatabaseInfo().getSqlCommandDelimiter();
            new SqlScript(alterSql, getSqlTemplate(), !continueOnError, false, false, delimiter, null).execute();
        } else {
            log.info("Tables up to date. No alters found for {}", tablesProcessed);
        }

    }

Activities

chenson

2013-04-26 13:11

administrator   ~0000248

This was intentional. We are only processing the tables specified in the database. We could probably clean up the api to allow the entire database to be diffed and to generate drops.

Issue History

Date Modified Username Field Change
2013-03-31 05:27 borball New Issue
2013-04-26 13:11 chenson Note Added: 0000248