Skip to content

Commit 7241a55

Browse files
authored
Use DropTableAction in create_table operation (#836)
This PR replaces the direct call to pg in the rollback phase of `create_table` with `DropTableAction`. Related to #742
1 parent 50d690a commit 7241a55

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

pkg/migrations/op_create_table.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"slices"
99
"strings"
1010

11-
"github.com/lib/pq"
12-
1311
"github.com/xataio/pgroll/pkg/db"
1412
"github.com/xataio/pgroll/pkg/schema"
1513
)
@@ -72,9 +70,7 @@ func (o *OpCreateTable) Complete(ctx context.Context, l Logger, conn db.DB, s *s
7270
func (o *OpCreateTable) Rollback(ctx context.Context, l Logger, conn db.DB, s *schema.Schema) error {
7371
l.LogOperationRollback(o)
7472

75-
_, err := conn.ExecContext(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s",
76-
pq.QuoteIdentifier(o.Name)))
77-
return err
73+
return NewDropTableAction(conn, o.Name).Execute(ctx)
7874
}
7975

8076
func (o *OpCreateTable) Validate(ctx context.Context, s *schema.Schema) error {

0 commit comments

Comments
 (0)