diff --git a/cli/version.go b/cli/version.go index 2a8bc5f..0b2b289 100644 --- a/cli/version.go +++ b/cli/version.go @@ -1,3 +1,3 @@ package cli -const Version = "0.0.4" +const Version = "0.0.5" diff --git a/plan/default.go b/plan/default.go index eb78a1f..d779496 100644 --- a/plan/default.go +++ b/plan/default.go @@ -5,9 +5,13 @@ import ( ) func setDefault(a, b *db.Column) bool { - return a.Default != b.Default && a.Default != "" + return !defaultEqual(a, b) && a.Default != "" } func dropDefault(a, b *db.Column) bool { - return a.Default != b.Default && b.Default != "" + return !defaultEqual(a, b) && b.Default != "" +} + +func defaultEqual(a, b *db.Column) bool { + return a.Default == b.Default || a.Default+"::"+a.DataType == b.Default } diff --git a/plan/default_test.go b/plan/default_test.go index 3d48afd..acca240 100644 --- a/plan/default_test.go +++ b/plan/default_test.go @@ -46,6 +46,18 @@ func TestSetDefault(t *testing.T) { &db.Column{}, true, }, + Test{ + `ignore type casting`, + &db.Column{ + DataType: "text", + Default: `''`, + }, + &db.Column{ + DataType: "text", + Default: `''::text`, + }, + false, + }, } for _, test := range tests { if setDefault(test.A, test.B) != test.SetDefault { @@ -94,6 +106,18 @@ func TestDropDefault(t *testing.T) { &db.Column{}, false, }, + Test{ + `ignore type casting`, + &db.Column{ + DataType: "text", + Default: `''`, + }, + &db.Column{ + DataType: "text", + Default: `''::text`, + }, + false, + }, } for _, test := range tests { if dropDefault(test.A, test.B) != test.DropDefault {