Package liquibase.statement

Examples of liquibase.statement.SequenceNextValueFunction


        addColumnChange.setCatalogName("cat");
        addColumnChange.addColumn((AddColumnConfig) new AddColumnConfig().setName("col1").setDefaultValueNumeric(3));
        addColumnChange.addColumn((AddColumnConfig) new AddColumnConfig().setName("col2").setDefaultValueComputed(new DatabaseFunction("NOW()")));
        addColumnChange.addColumn((AddColumnConfig) new AddColumnConfig().setName("col3").setDefaultValueBoolean(true));
        addColumnChange.addColumn((AddColumnConfig) new AddColumnConfig().setName("col2").setDefaultValueDate(new Date(0)));
        addColumnChange.addColumn((AddColumnConfig) new AddColumnConfig().setName("col2").setDefaultValueSequenceNext(new SequenceNextValueFunction("seq_me")));

        ChangeSet changeSet = new ChangeSet("1", "nvoxland", false, false, "path/to/file.json", null, null, null);
        changeSet.addChange(addColumnChange);
        assertEquals("{\n" +
                "  \"changeSet\": {\n" +
View Full Code Here


        if (valueComputedString != null) {
            valueComputed = new DatabaseFunction(valueComputedString);
        }
        String valueSequenceNextString = parsedNode.getChildValue(null, "valueSequenceNext", String.class);
        if (valueSequenceNextString != null) {
            valueSequenceNext = new SequenceNextValueFunction(valueSequenceNextString);
        }
        String valueSequenceCurrentString = parsedNode.getChildValue(null, "valueSequenceCurrent", String.class);
        if (valueSequenceCurrentString != null) {
            valueSequenceCurrent = new SequenceCurrentValueFunction(valueSequenceCurrentString);
        }


        defaultValue = parsedNode.getChildValue(null, "defaultValue", String.class);
       
        setDefaultValueNumeric(parsedNode.getChildValue(null, "defaultValueNumeric", String.class));

        try {
            defaultValueDate = parsedNode.getChildValue(null, "defaultValueDate", Date.class);
        } catch (ParsedNodeException e) {
            defaultValueComputed = new DatabaseFunction(parsedNode.getChildValue(null, "defaultValueDate", String.class));
        }
        defaultValueBoolean = parsedNode.getChildValue(null, "defaultValueBoolean", Boolean.class);
        String defaultValueComputedString = parsedNode.getChildValue(null, "defaultValueComputed", String.class);
        if (defaultValueComputedString != null) {
            defaultValueComputed = new DatabaseFunction(defaultValueComputedString);
        }
        String defaultValueSequenceNextString = parsedNode.getChildValue(null, "defaultValueSequenceNext", String.class);
        if (defaultValueSequenceNextString != null) {
            defaultValueSequenceNext = new SequenceNextValueFunction(defaultValueSequenceNextString);
        }

        loadConstraints(parsedNode.getChild(null, "constraints"));
    }
View Full Code Here

        } else if (parameterType.equals(BigInteger.class)) {
            finalValue = new BigInteger(propertyValue);
        } else if (parameterType.equals(DatabaseFunction.class)) {
            finalValue = new DatabaseFunction(propertyValue);
        } else if (parameterType.equals(SequenceNextValueFunction.class)) {
            finalValue = new SequenceNextValueFunction(propertyValue);
        } else if (parameterType.equals(SequenceCurrentValueFunction.class)) {
            finalValue = new SequenceCurrentValueFunction(propertyValue);
        } else if (Enum.class.isAssignableFrom(parameterType)) {
            finalValue = Enum.valueOf((Class<Enum>) parameterType, propertyValue);
        }
View Full Code Here

        } else if (dataType.equals("bigInteger")) {
            return new BigInteger("371717");
        } else if (dataType.equals("list")) {
            return null; //"TODO";
        } else if (dataType.equals("sequenceNextValueFunction")) {
            return new SequenceNextValueFunction("seq_name");
        } else if (dataType.equals("databaseFunction")) {
            return new DatabaseFunction("now");
        } else if (dataType.equals("list of columnConfig")) {
            ArrayList<ColumnConfig> list = new ArrayList<ColumnConfig>();
            list.add(new ColumnConfig().setName("id").setType("int"));
View Full Code Here

        if (database instanceof PostgresDatabase) {
            String sequenceName = (getTableName() + "_" + getColumnName() + "_seq").toLowerCase();
            return new SqlStatement[]{
                    new CreateSequenceStatement(catalogName, schemaName, sequenceName),
                    new SetNullableStatement(catalogName, schemaName, getTableName(), getColumnName(), null, false),
                    new AddDefaultValueStatement(catalogName, schemaName, getTableName(), getColumnName(), getColumnDataType(), new SequenceNextValueFunction(sequenceName)),
            };
        }

        return new SqlStatement[]{new AddAutoIncrementStatement(getCatalogName(), getSchemaName(), getTableName(), getColumnName(), getColumnDataType(), getStartWith(), getIncrementBy())};
    }
View Full Code Here

        change.setColumnName("COLUMN_NAME");
        change.setDefaultValue("DEF STRING");
        change.setDefaultValueNumeric("42");
        change.setDefaultValueBoolean(true);
        change.setDefaultValueDate("2007-01-02");
        change.setDefaultValueSequenceNext(new SequenceNextValueFunction("sampleSeq"));

        Element node = new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(change);
        assertEquals("addDefaultValue", node.getTagName());
        assertEquals("SCHEMA_NAME", node.getAttribute("schemaName"));
        assertEquals("TABLE_NAME", node.getAttribute("tableName"));
View Full Code Here

        }

        List<Sql> commands = new ArrayList<Sql>(Arrays.asList(super.generateSql(statement, database, sqlGeneratorChain)));
        // for postgres, we need to also set the sequence to be owned by this table for true serial like functionality.
        // this will allow a drop table cascade to remove the sequence as well.
        SequenceNextValueFunction sequenceFunction = (SequenceNextValueFunction) statement.getDefaultValue();

        Sql alterSequenceOwner = new UnparsedSql("ALTER SEQUENCE " + database.escapeSequenceName(statement.getCatalogName(),
                statement.getSchemaName(), sequenceFunction.getValue()) + " OWNED BY " +
                database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) + "."
                + database.escapeObjectName(statement.getColumnName(), Column.class),
                getAffectedColumn(statement),
                getAffectedSequence(sequenceFunction));
        commands.add(alterSequenceOwner);
View Full Code Here

        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("boolean").setDefaultValueBoolean(false));
        columnConfigs.add((AddColumnConfig) new AddColumnConfig().setName("test_col").setType("boolean").setDefaultValueBoolean(true));
        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)));
View Full Code Here

            } else if (type.equals(Boolean.class) && rawValue instanceof String) {
                return (T) Boolean.valueOf(rawValue.toString());
            } else if (type.isAssignableFrom(Date.class)) {
                return (T) new ISODateFormat().parse(rawValue.toString());
            } else if (type.equals(SequenceNextValueFunction.class)) {
                return (T) new SequenceNextValueFunction(rawValue.toString());
            } else if (type.equals(SequenceCurrentValueFunction.class)) {
                return (T) new SequenceCurrentValueFunction(rawValue.toString());
            } else if (type.equals(DatabaseFunction.class)) {
                return (T) new DatabaseFunction(rawValue.toString());
            } else {
View Full Code Here

TOP

Related Classes of liquibase.statement.SequenceNextValueFunction

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.