Skip to content

Commit

Permalink
Add testcase for more complex default expression
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Dec 16, 2024
1 parent a1556dd commit 15c3f2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql2pgroll/alter_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql2pgroll/expect/alter_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 15c3f2e

Please sign in to comment.