16
21
* Creates a new instance of PgDiffSequences.
18
23
private PgDiffSequences() {
23
* Outputs commands for creation of new sequences.
27
* Outputs statements for creation of new sequences.
25
29
* @param writer writer the output should be written to
26
* @param arguments object containing arguments settings
27
30
* @param oldSchema original schema
28
31
* @param newSchema new schema
32
* @param searchPathHelper search path helper
30
34
public static void createSequences(final PrintWriter writer,
31
final PgDiffArguments arguments, final PgSchema oldSchema,
32
final PgSchema newSchema) {
35
final PgSchema oldSchema, final PgSchema newSchema,
36
final SearchPathHelper searchPathHelper) {
33
37
// Add new sequences
34
38
for (final PgSequence sequence : newSchema.getSequences()) {
35
39
if (oldSchema == null
36
40
|| !oldSchema.containsSequence(sequence.getName())) {
41
searchPathHelper.outputSearchPath(writer);
39
sequence.getCreationSQL(arguments.isQuoteNames()));
43
writer.println(sequence.getCreationSQL());
45
* Outputs commands for dropping of sequences that do not exist anymore.
49
* Outputs statements for dropping of sequences that do not exist anymore.
47
51
* @param writer writer the output should be written to
48
* @param arguments object containing arguments settings
49
52
* @param oldSchema original schema
50
53
* @param newSchema new schema
54
* @param searchPathHelper search path helper
52
56
public static void dropSequences(final PrintWriter writer,
53
final PgDiffArguments arguments, final PgSchema oldSchema,
54
final PgSchema newSchema) {
57
final PgSchema oldSchema, final PgSchema newSchema,
58
final SearchPathHelper searchPathHelper) {
55
59
// Drop sequences that do not exist in new schema
56
60
if (oldSchema != null) {
57
61
for (final PgSequence sequence : oldSchema.getSequences()) {
58
62
if (!newSchema.containsSequence(sequence.getName())) {
63
searchPathHelper.outputSearchPath(writer);
61
sequence.getDropSQL(arguments.isQuoteNames()));
65
writer.println(sequence.getDropSQL());
68
* Outputs command for modified sequences.
72
* Outputs statement for modified sequences.
70
74
* @param writer writer the output should be written to
71
75
* @param arguments object containing arguments settings
72
76
* @param oldSchema original schema
73
77
* @param newSchema new schema
78
* @param searchPathHelper search path helper
75
80
public static void alterSequences(final PrintWriter writer,
76
81
final PgDiffArguments arguments, final PgSchema oldSchema,
77
final PgSchema newSchema) {
78
final StringBuilder sbSQL = new StringBuilder();
82
final PgSchema newSchema, final SearchPathHelper searchPathHelper) {
83
final StringBuilder sbSQL = new StringBuilder(100);
80
85
for (final PgSequence newSequence : newSchema.getSequences()) {
81
86
if (oldSchema != null