1 | |
package liquibase.change.core; |
2 | |
|
3 | |
import liquibase.change.AbstractChange; |
4 | |
import liquibase.change.ChangeMetaData; |
5 | |
import liquibase.database.Database; |
6 | |
import liquibase.statement.SqlStatement; |
7 | |
import liquibase.statement.core.AlterSequenceStatement; |
8 | |
import liquibase.util.StringUtils; |
9 | |
|
10 | |
import java.math.BigInteger; |
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
public class AlterSequenceChange extends AbstractChange { |
16 | |
|
17 | |
private String schemaName; |
18 | |
private String sequenceName; |
19 | |
private BigInteger incrementBy; |
20 | |
private BigInteger maxValue; |
21 | |
private BigInteger minValue; |
22 | |
private Boolean ordered; |
23 | |
|
24 | |
|
25 | |
|
26 | |
public AlterSequenceChange() { |
27 | 18 | super("alterSequence", "Alter Sequence", ChangeMetaData.PRIORITY_DEFAULT); |
28 | 18 | } |
29 | |
|
30 | |
public String getSchemaName() { |
31 | 41 | return schemaName; |
32 | |
} |
33 | |
|
34 | |
public void setSchemaName(String schemaName) { |
35 | 2 | this.schemaName = StringUtils.trimToNull(schemaName); |
36 | 2 | } |
37 | |
|
38 | |
public String getSequenceName() { |
39 | 41 | return sequenceName; |
40 | |
} |
41 | |
|
42 | |
public void setSequenceName(String sequenceName) { |
43 | 4 | this.sequenceName = sequenceName; |
44 | 4 | } |
45 | |
|
46 | |
public BigInteger getIncrementBy() { |
47 | 40 | return incrementBy; |
48 | |
} |
49 | |
|
50 | |
public void setIncrementBy(BigInteger incrementBy) { |
51 | 2 | this.incrementBy = incrementBy; |
52 | 2 | } |
53 | |
|
54 | |
public BigInteger getMaxValue() { |
55 | 40 | return maxValue; |
56 | |
} |
57 | |
|
58 | |
public void setMaxValue(BigInteger maxValue) { |
59 | 2 | this.maxValue = maxValue; |
60 | 2 | } |
61 | |
|
62 | |
public BigInteger getMinValue() { |
63 | 40 | return minValue; |
64 | |
} |
65 | |
|
66 | |
public void setMinValue(BigInteger minValue) { |
67 | 2 | this.minValue = minValue; |
68 | 2 | } |
69 | |
|
70 | |
public Boolean isOrdered() { |
71 | 40 | return ordered; |
72 | |
} |
73 | |
|
74 | |
public void setOrdered(Boolean ordered) { |
75 | 2 | this.ordered = ordered; |
76 | 2 | } |
77 | |
|
78 | |
public SqlStatement[] generateStatements(Database database) { |
79 | 40 | return new SqlStatement[] { new AlterSequenceStatement( |
80 | |
getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(), getSequenceName()) |
81 | |
.setIncrementBy(getIncrementBy()).setMaxValue(getMaxValue()).setMinValue(getMinValue()) |
82 | |
.setOrdered(isOrdered()) }; |
83 | |
} |
84 | |
|
85 | |
public String getConfirmationMessage() { |
86 | 1 | return "Sequence " + getSequenceName() + " altered"; |
87 | |
} |
88 | |
} |