Package liquibase.statement.core

Examples of liquibase.statement.core.DropColumnStatement


    @Override
    public ValidationErrors validate(DropColumnStatement dropColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        if (dropColumnStatement.isMultiple()) {
            ValidationErrors validationErrors = new ValidationErrors();
            DropColumnStatement firstColumn = dropColumnStatement.getColumns().get(0);

            for (DropColumnStatement drop : dropColumnStatement.getColumns()) {
                validationErrors.addAll(validateSingleColumn(drop));
                if (drop.getTableName() != null && !drop.getTableName().equals(firstColumn.getTableName())) {
                    validationErrors.addError("All columns must be targeted at the same table");
                }
                if (drop.isMultiple()) {
                    validationErrors.addError("Nested multiple drop column statements are not supported");
                }
View Full Code Here


        super(new DropColumnGenerator());
    }

    @Override
    protected DropColumnStatement createSampleSqlStatement() {
        return new DropColumnStatement(null, null, "TEST_TABLE", "test_col");
    }
View Full Code Here

        return new DropColumnStatement(null, null, "TEST_TABLE", "test_col");
    }

    @Test
    public void testDropMultipleColumnsMySQL() {
        DropColumnStatement drop = new DropColumnStatement(Arrays.asList(
            new DropColumnStatement(null, null, "TEST_TABLE", "col1"),
            new DropColumnStatement(null, null, "TEST_TABLE", "col2")
        ));

        Assert.assertFalse(generatorUnderTest.validate(drop, new MySQLDatabase(), new MockSqlGeneratorChain()).hasErrors());
        Sql[] sql = generatorUnderTest.generateSql(drop, new MySQLDatabase(), new MockSqlGeneratorChain());
        Assert.assertEquals(1, sql.length);
View Full Code Here

        change.addColumn(column2);

        SqlStatement[] statements = change.generateStatements(new MockDatabase());
        Assert.assertEquals(1, statements.length);
        Assert.assertTrue(statements[0] instanceof DropColumnStatement);
        DropColumnStatement stmt = (DropColumnStatement)statements[0];
        Assert.assertTrue(stmt.isMultiple());
        Assert.assertEquals(2, stmt.getColumns().size());
    }
View Full Code Here

        for (ColumnConfig column : columns) {
            if (database instanceof SQLiteDatabase) {
                statements.addAll(Arrays.asList(generateStatementsForSQLiteDatabase(database, column.getName())));
            } else {
                dropStatements.add(new DropColumnStatement(getCatalogName(), getSchemaName(), getTableName(), column.getName()));
            }
        }

        if (dropStatements.size() == 1) {
            statements.add(dropStatements.get(0));
        } else {
            statements.add(new DropColumnStatement(dropStatements));
        }

        if (database instanceof DB2Database) {
            statements.add(new ReorganizeTableStatement(getCatalogName(), getSchemaName(), getTableName()));
        }
View Full Code Here

            return generateStatementsForSQLiteDatabase(database, getColumnName());
        }

        List<SqlStatement> statements = new ArrayList<SqlStatement>();

        statements.add(new DropColumnStatement(getCatalogName(), getSchemaName(), getTableName(), getColumnName()));
        if (database instanceof DB2Database) {
            statements.add(new ReorganizeTableStatement(getCatalogName(), getSchemaName(), getTableName()));
        }

        return statements.toArray(new SqlStatement[statements.size()]);
View Full Code Here

TOP

Related Classes of liquibase.statement.core.DropColumnStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.