Package liquibase.change

Examples of liquibase.change.ConstraintsConfig


        column.setName("id");
        column.setType("varchar(255)");
        column.setDefaultValue("test Value");
        column.setValue("some value here");

        ConstraintsConfig constraints = new ConstraintsConfig();
        constraints.setDeferrable(Boolean.TRUE);
        constraints.setDeleteCascade(true);
        constraints.setForeignKeyName("FK_NAME");
        constraints.setInitiallyDeferred(true);
        constraints.setNullable(false);
        constraints.setPrimaryKey(true);
        constraints.setReferences("state(id)");
        constraints.setUnique(true);
        column.setConstraints(constraints);

        Element element = new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(column);
        assertEquals("column", element.getTagName());
        assertEquals("id", element.getAttribute("name"));
View Full Code Here


        change.setTableName("TABLE_NAME");

        ColumnConfig column1 = new ColumnConfig();
        column1.setName("id");
        column1.setType("int");
        ConstraintsConfig column1constraints = new ConstraintsConfig();
        column1constraints.setPrimaryKey(true);
        column1constraints.setNullable(false);
        column1.setConstraints(column1constraints);
        change.addColumn(column1);

        ColumnConfig column2 = new ColumnConfig();
        column2.setName("name");
        column2.setType("varchar(255)");
        change.addColumn(column2);

        ColumnConfig column3 = new ColumnConfig();
        column3.setName("state_id");
        ConstraintsConfig column3constraints = new ConstraintsConfig();
        column3constraints.setNullable(false);
        column3constraints.setInitiallyDeferred(true);
        column3constraints.setDeferrable(true);
        column3constraints.setForeignKeyName("fk_tab_ref");
        column3constraints.setReferences("state(id)");
        column3.setConstraints(column3constraints);
        change.addColumn(column3);

        ColumnConfig column4 = new ColumnConfig();
        column4.setName("phone");
        column4.setType("varchar(255)");
        column4.setDefaultValue("NOPHONE");
        change.addColumn(column4);

        ColumnConfig column5 = new ColumnConfig();
        column5.setName("phone2");
        column5.setType("varchar(255)");
        ConstraintsConfig column5constraints = new ConstraintsConfig();
        column5constraints.setUnique(true);
        column5.setConstraints(column5constraints);
        change.addColumn(column5);

        Element element = new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(change);
        assertEquals("createTable", element.getTagName());
View Full Code Here

    public Change[]  prepareDatabase(DropForeignKeyConstraintChange change) throws DatabaseException {
        CreateTableChange createBaseTable = new CreateTableChange();
        createBaseTable.setCatalogName(change.getBaseTableCatalogName());
        createBaseTable.setSchemaName(change.getBaseTableSchemaName());
        createBaseTable.setTableName(change.getBaseTableName());
        createBaseTable.addColumn(new ColumnConfig().setName("id").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)));
        createBaseTable.addColumn(new ColumnConfig().setName("customer_id").setType("int"));

        AddForeignKeyConstraintChange createFKChange = new AddForeignKeyConstraintChange();
        createFKChange.setBaseTableCatalogName(change.getBaseTableCatalogName());
        createFKChange.setBaseTableSchemaName(change.getBaseTableSchemaName());
View Full Code Here

    public Change[]  prepareDatabase(DropPrimaryKeyChange change) throws DatabaseException {
        CreateTableChange createTableChange = new CreateTableChange();
        createTableChange.setCatalogName(change.getCatalogName());
        createTableChange.setSchemaName(change.getSchemaName());
        createTableChange.setTableName(change.getTableName());
        createTableChange.addColumn(new ColumnConfig().setName("id").setType("int").setConstraints(new ConstraintsConfig().setNullable(false).setPrimaryKey(true).setPrimaryKeyName(change.getConstraintName())));
        createTableChange.addColumn(new ColumnConfig().setName("not_id").setType("int"));

        return new Change[] {createTableChange };
    }
View Full Code Here

    public Change[]  prepareDatabase(DropTableChange change) throws DatabaseException {
        CreateTableChange createTableChange = new CreateTableChange();
        createTableChange.setCatalogName(change.getCatalogName());
        createTableChange.setSchemaName(change.getSchemaName());
        createTableChange.setTableName(change.getTableName());
        createTableChange.addColumn(new ColumnConfig().setName("id").setType("int").setConstraints(new ConstraintsConfig().setNullable(false).setPrimaryKey(true)));
        createTableChange.addColumn(new ColumnConfig().setName("not_id").setType("int"));

        return new Change[] {createTableChange };
    }
View Full Code Here

    public Change[] prepareDatabase(CreateProcedureChange change) throws Exception {
        CreateTableChange createTableChange = new CreateTableChange();
        createTableChange.setCatalogName(change.getCatalogName());
        createTableChange.setSchemaName(change.getSchemaName());
        createTableChange.setTableName("customers");
        createTableChange.addColumn(new ColumnConfig().setName("id").setType("int").setConstraints(new ConstraintsConfig().setNullable(false).setPrimaryKey(true)).setAutoIncrement(true));
        createTableChange.addColumn(new ColumnConfig().setName("first_name").setType("varchar(50)"));
        createTableChange.addColumn(new ColumnConfig().setName("last_name").setType("varchar(50)"));

        return new Change[] {createTableChange };
View Full Code Here

    @Override
    public Change[] prepareDatabase(SQLFileChange change) throws Exception {
        CreateTableChange createTableChange = new CreateTableChange();
        createTableChange.setTableName("person");
        createTableChange.addColumn(new ColumnConfig().setName("id").setType("int").setConstraints(new ConstraintsConfig().setNullable(false).setPrimaryKey(true)));
        createTableChange.addColumn(new ColumnConfig().setName("not_id").setType("int"));

        return new Change[] {createTableChange };
    }
View Full Code Here

            @Override
            public boolean createThisColumn(ColumnConfig column) {
                if (column.getName().equals(statement.getColumnName())) {
                    column.setAutoIncrement(true);
                    column.setConstraints(new ConstraintsConfig().setPrimaryKey(true));
                    column.setType("INTEGER");
                }
                return true;
            }
View Full Code Here

        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("datetime").setDefaultValueComputed(new DatabaseFunction("NOW()")));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("datetime").setDefaultValueDate(new Date(737138163)));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("datetime").setDefaultValueDate("2013-02-13T13:44:03"));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("datetime").setDefaultValueSequenceNext(new SequenceNextValueFunction("seq_test")));

        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)).setDefaultValueNumeric(-1));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)).setAutoIncrement(true));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)).setAutoIncrement(true).setStartWith(BigInteger.valueOf(3)));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)).setAutoIncrement(true).setIncrementBy(BigInteger.valueOf(4)));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("int").setConstraints(new ConstraintsConfig().setPrimaryKey(true)).setAutoIncrement(true).setStartWith(BigInteger.valueOf(3)).setIncrementBy(BigInteger.valueOf(4)));

        return columnConfigs;
    }
View Full Code Here

        createTable.setTableName(change.getTableName());
        String dataType = change.getColumnDataType();
        if (dataType == null) {
            dataType = "int";
        }
        createTable.addColumn(new ColumnConfig().setName(change.getColumnName()).setType(dataType).setConstraints(new ConstraintsConfig().setPrimaryKey(true).setNullable(false)));

        return new Change[] {createTable};
    }
View Full Code Here

TOP

Related Classes of liquibase.change.ConstraintsConfig

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.