Skip to content

Commit

Permalink
0000818: Support alters tables statements for column size changes in …
Browse files Browse the repository at this point in the history
…postgres
  • Loading branch information
chenson42 committed Sep 12, 2012
1 parent 7708a1b commit 94af989
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Expand Up @@ -25,8 +25,6 @@

/**
* Represents the change of the size or scale of a column.
*
* @version $Revision: $
*/
public class ColumnSizeChange extends TableChangeImplBase implements ColumnChange
{
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.jumpmind.db.alter.ColumnDataTypeChange;
import org.jumpmind.db.alter.ColumnDefaultValueChange;
import org.jumpmind.db.alter.ColumnRequiredChange;
import org.jumpmind.db.alter.ColumnSizeChange;
import org.jumpmind.db.alter.PrimaryKeyChange;
import org.jumpmind.db.alter.RemoveColumnChange;
import org.jumpmind.db.alter.TableChange;
Expand Down Expand Up @@ -268,8 +269,11 @@ protected void processTableStructureChanges(Database currentModel, Database desi
} else if (change instanceof ColumnRequiredChange) {
processChange(currentModel, desiredModel, (ColumnRequiredChange) change, ddl);
changeIt.remove();
} else if (change instanceof ColumnSizeChange) {
processChange(currentModel, desiredModel, (ColumnSizeChange) change, ddl);
changeIt.remove();
} else if (change instanceof PrimaryKeyChange) {
processChange(currentModel, desiredModel, (PrimaryKeyChange)change, ddl);
processChange(currentModel, desiredModel, (PrimaryKeyChange) change, ddl);
changeIt.remove();
} else if (change instanceof ColumnAutoIncrementChange) {
if (processChange(currentModel, desiredModel, (ColumnAutoIncrementChange) change,
Expand All @@ -281,7 +285,7 @@ protected void processTableStructureChanges(Database currentModel, Database desi
super.processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable,
changes, ddl);
}

protected void processChange(Database currentModel, Database desiredModel,
PrimaryKeyChange change, StringBuilder ddl) {
ddl.append("ALTER TABLE ");
Expand All @@ -297,7 +301,7 @@ protected void processChange(Database currentModel, Database desiredModel,
ddl.append(" ADD ");
writePrimaryKeyStmt(change.getChangedTable(), change.getNewPrimaryKeyColumns(), ddl);
printEndOfStatement(ddl);

}

/*
Expand Down Expand Up @@ -367,6 +371,17 @@ protected void processChange(Database currentModel, Database desiredModel,
printEndOfStatement(ddl);
}

protected void processChange(Database currentModel, Database desiredModel,
ColumnSizeChange change, StringBuilder ddl) {
writeTableAlterStmt(change.getChangedTable(), ddl);
ddl.append(" ALTER COLUMN ");
Column column = change.getChangedColumn();
printIdentifier(getColumnName(column), ddl);
ddl.append(" TYPE ");
ddl.append(getSqlType(column));
printEndOfStatement(ddl);
}

protected boolean processChange(Database currentModel, Database desiredModel,
ColumnAutoIncrementChange change, StringBuilder ddl) {
boolean autoIncrement = !change.getColumn().isAutoIncrement();
Expand Down

0 comments on commit 94af989

Please sign in to comment.