Skip to content

Commit

Permalink
run DROP COLUMN for ONLY table
Browse files Browse the repository at this point in the history
  • Loading branch information
Endeavourl committed Apr 22, 2019
1 parent ba86661 commit 212e85e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void setLocation(PgObjLocation location) {
getMeta().setLocation(location);
}

protected String getAlterTable() {
return ((AbstractTable) getParent()).getAlterTable(false, false);
protected String getAlterTable(boolean nextLine, boolean only) {
return ((AbstractTable) getParent()).getAlterTable(nextLine, only);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String getFullDefinition() {
public String getCreationSQL() {
StringBuilder sb = new StringBuilder();

sb.append(getAlterTable());
sb.append(getAlterTable(false, false));
sb.append("\n\tADD ").append(MsDiffUtils.quoteName(name)).append(' ');
if (getExpression() != null) {
sb.append("AS ").append(getExpression());
Expand Down Expand Up @@ -192,13 +192,13 @@ private void compareDefaults(String oldDefaultName, String oldDefault,
if (!Objects.equals(oldDefault, newDefault)
|| !Objects.equals(oldDefaultName, newDefaultName)) {
if (oldDefault != null) {
sb.append(((AbstractTable)this.getParent()).getAlterTable(true, false));
sb.append(getAlterTable(true, false));
sb.append(" DROP CONSTRAINT ").append(MsDiffUtils.quoteName(oldDefaultName));
sb.append(GO);
}

if (newDefault != null) {
sb.append(((AbstractTable)this.getParent()).getAlterTable(true, false));
sb.append(getAlterTable(true, false));
sb.append(" ADD CONSTRAINT ").append(MsDiffUtils.quoteName(newDefaultName));
sb.append(" DEFAULT ").append(newDefault);
sb.append(" FOR ").append(MsDiffUtils.quoteName(name));
Expand Down Expand Up @@ -259,7 +259,7 @@ private String getAlterColumn(boolean newLine, boolean only, String column) {

@Override
public String getDropSQL() {
return getAlterTable() + "\n\tDROP COLUMN " + MsDiffUtils.getQuotedName(getName()) + GO;
return getAlterTable(false, false) + "\n\tDROP COLUMN " + MsDiffUtils.getQuotedName(getName()) + GO;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public String getCreationSQL() {
StringBuilder sb = new StringBuilder();

if (getType() != null) {
sb.append(getAlterTable());
sb.append(getAlterTable(false, false));
sb.append("\n\tADD COLUMN ")
.append(PgDiffUtils.getQuotedName(name))
.append(' ')
Expand Down Expand Up @@ -108,7 +108,7 @@ private String getAlterColumn(boolean newLine, boolean only, String column) {
@Override
public String getDropSQL() {
if (getType() != null) {
return getAlterTable() + "\n\tDROP COLUMN "
return getAlterTable(false, true) + "\n\tDROP COLUMN "
+ PgDiffUtils.getQuotedName(getName()) + ';';
}

Expand Down

0 comments on commit 212e85e

Please sign in to comment.