@@ -42,6 +42,8 @@ public class Alter implements Statement {
4242 private List <String > ukColumns ;
4343 private String ukName ;
4444 private ForeignKeyIndex fkIndex = null ;
45+ private String operation ;
46+ private String constraintName ;
4547
4648 private boolean onDeleteCascade ;
4749
@@ -93,6 +95,14 @@ public void setFkSourceTable(String fkSourceTable) {
9395 this .fkSourceTable = fkSourceTable ;
9496 }
9597
98+ public String getOperation () {
99+ return operation ;
100+ }
101+
102+ public void setOperation (String operation ) {
103+ this .operation = operation ;
104+ }
105+
96106 private List <String > fkSourceColumns ;
97107
98108 public List <String > getFkSourceColumns () {
@@ -119,6 +129,14 @@ public void setColumnName(String columnName) {
119129 this .columnName = columnName ;
120130 }
121131
132+ public String getConstraintName () {
133+ return this .constraintName ;
134+ }
135+
136+ public void setConstraintName (final String constraintName ) {
137+ this .constraintName = constraintName ;
138+ }
139+
122140 public ColDataType getDataType () {
123141 return dataType ;
124142 }
@@ -167,9 +185,14 @@ public void setFkIndex(ForeignKeyIndex fkIndex) {
167185 @ Override
168186 public String toString () {
169187 StringBuilder b = new StringBuilder ();
170- b .append ("ALTER TABLE " ).append (table .getFullyQualifiedName ()).append (" ADD " );
188+ b .append ("ALTER TABLE " ).append (table .getFullyQualifiedName ()).append (" " ). append ( operation ). append ( " " );
171189 if (columnName != null ) {
172- b .append ("COLUMN " ).append (columnName ).append (" " ).append (dataType .toString ());
190+ b .append ("COLUMN " ).append (columnName );
191+ if (dataType != null ) {
192+ b .append (" " ).append (dataType .toString ());
193+ }
194+ } else if (constraintName != null ) {
195+ b .append ("CONSTRAINT " ).append (constraintName );
173196 } else if (pkColumns != null ) {
174197 b .append ("PRIMARY KEY (" ).append (PlainSelect .getStringList (pkColumns )).append (")" );
175198 } else if (ukColumns != null ) {
0 commit comments