liquibase.change.core.AlterSequenceChange Maven / Gradle / Ivy
package liquibase.change.core;
import liquibase.change.AbstractChange;
import liquibase.change.DatabaseChange;
import liquibase.change.ChangeMetaData;
import liquibase.change.DatabaseChangeProperty;
import liquibase.database.Database;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.AlterSequenceStatement;
import java.math.BigInteger;
/**
* Modifies properties of an existing sequence. StartValue is not allowed since we cannot alter the starting sequence number
*/
@DatabaseChange(name="alterSequence", description = "Alter properties of an existing sequence", priority = ChangeMetaData.PRIORITY_DEFAULT, appliesTo = "sequence")
public class AlterSequenceChange extends AbstractChange {
private String catalogName;
private String schemaName;
private String sequenceName;
private BigInteger incrementBy;
private BigInteger maxValue;
private BigInteger minValue;
private Boolean ordered;
@DatabaseChangeProperty(mustEqualExisting ="sequence.catalog", since = "3.0")
public String getCatalogName() {
return catalogName;
}
public void setCatalogName(String catalogName) {
this.catalogName = catalogName;
}
@DatabaseChangeProperty(mustEqualExisting ="sequence.schema")
public String getSchemaName() {
return schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
@DatabaseChangeProperty(mustEqualExisting = "sequence")
public String getSequenceName() {
return sequenceName;
}
public void setSequenceName(String sequenceName) {
this.sequenceName = sequenceName;
}
@DatabaseChangeProperty(description = "New amount the sequence should increment by")
public BigInteger getIncrementBy() {
return incrementBy;
}
public void setIncrementBy(BigInteger incrementBy) {
this.incrementBy = incrementBy;
}
@DatabaseChangeProperty(description = "New maximum value for the sequence")
public BigInteger getMaxValue() {
return maxValue;
}
public void setMaxValue(BigInteger maxValue) {
this.maxValue = maxValue;
}
@DatabaseChangeProperty(description = "New minimum value for the sequence")
public BigInteger getMinValue() {
return minValue;
}
public void setMinValue(BigInteger minValue) {
this.minValue = minValue;
}
@DatabaseChangeProperty(description = "Does the sequence need to be guaranteed to be genererated inm the order of request?")
public Boolean isOrdered() {
return ordered;
}
public void setOrdered(Boolean ordered) {
this.ordered = ordered;
}
@Override
public SqlStatement[] generateStatements(Database database) {
return new SqlStatement[] {
new AlterSequenceStatement(getCatalogName(), getSchemaName(), getSequenceName())
.setIncrementBy(getIncrementBy())
.setMaxValue(getMaxValue())
.setMinValue(getMinValue())
.setOrdered(isOrdered())
};
}
@Override
public String getConfirmationMessage() {
return "Sequence " + getSequenceName() + " altered";
}
@Override
public String getSerializedObjectNamespace() {
return STANDARD_CHANGELOG_NAMESPACE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy