Skip to content

Commit

Permalink
fix: diff logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokent committed Jan 31, 2024
1 parent da0c494 commit 6bfd914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
10 changes: 4 additions & 6 deletions pkg/ddl/mysql/diff_create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,10 @@ func (config *DiffCreateTableConfig) diffCreateTableColumn(ddls *DDL, before, af
if beforeColumn.DataType.StringForDiff() != afterColumn.DataType.StringForDiff() ||
beforeColumn.CharacterSet.StringForDiff() != afterColumn.CharacterSet.StringForDiff() ||
beforeColumn.Collate.StringForDiff() != afterColumn.Collate.StringForDiff() ||
(beforeColumn.NotNull && !afterColumn.NotNull) ||
(!beforeColumn.NotNull && afterColumn.NotNull) ||
(beforeColumn.AutoIncrement && !afterColumn.AutoIncrement) ||
(!beforeColumn.AutoIncrement && afterColumn.AutoIncrement) ||
(beforeColumn.OnAction != afterColumn.OnAction) ||
(beforeColumn.Comment != afterColumn.Comment) {
beforeColumn.NotNull != afterColumn.NotNull ||
beforeColumn.AutoIncrement != afterColumn.AutoIncrement ||
beforeColumn.OnAction != afterColumn.OnAction ||
beforeColumn.Comment != afterColumn.Comment {
// ALTER TABLE table_name MODIFY column_name data_type NOT NULL;
ddls.Stmts = append(ddls.Stmts, &AlterTableStmt{
Comment: simplediff.Diff(beforeColumn.String(), afterColumn.String()).String(),
Expand Down
3 changes: 1 addition & 2 deletions pkg/ddl/spanner/diff_create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ func (config *DiffCreateTableConfig) diffCreateTableColumn(ddls *DDL, before, af
}

if beforeColumn.DataType.StringForDiff() != afterColumn.DataType.StringForDiff() ||
beforeColumn.NotNull && !afterColumn.NotNull ||
!beforeColumn.NotNull && afterColumn.NotNull {
beforeColumn.NotNull != afterColumn.NotNull {
// ALTER TABLE table_name ALTER COLUMN column_name data_type NOT NULL;
ddls.Stmts = append(ddls.Stmts, &AlterTableStmt{
Comment: simplediff.Diff(beforeColumn.String(), afterColumn.String()).String(),
Expand Down

0 comments on commit 6bfd914

Please sign in to comment.