diff --git a/pkg/sql2pgroll/alter_table_test.go b/pkg/sql2pgroll/alter_table_test.go index 90b47af6..071a1410 100644 --- a/pkg/sql2pgroll/alter_table_test.go +++ b/pkg/sql2pgroll/alter_table_test.go @@ -68,6 +68,10 @@ func TestConvertAlterTableStatements(t *testing.T) { sql: "ALTER TABLE foo ALTER COLUMN bar SET DEFAULT now()", expectedOp: expect.AlterColumnOp11, }, + { + sql: "ALTER TABLE foo ALTER COLUMN bar SET DEFAULT (first_name || ' ' || last_name)", + expectedOp: expect.AlterColumnOp12, + }, { sql: "ALTER TABLE foo ADD CONSTRAINT bar UNIQUE (a)", expectedOp: expect.CreateConstraintOp1, diff --git a/pkg/sql2pgroll/expect/alter_column.go b/pkg/sql2pgroll/expect/alter_column.go index 2e4562dd..adfdbd57 100644 --- a/pkg/sql2pgroll/expect/alter_column.go +++ b/pkg/sql2pgroll/expect/alter_column.go @@ -95,6 +95,10 @@ var AlterColumnOp11 = &migrations.OpAlterColumn{ Down: sql2pgroll.PlaceHolderSQL, } +var AlterColumnOp12 = &migrations.OpAlterColumn{ + Table: "foo", + Column: "bar", + Default: nullable.NewNullableWithValue("(first_name || ' ') || last_name"), Up: sql2pgroll.PlaceHolderSQL, Down: sql2pgroll.PlaceHolderSQL, }