-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert DROP CONSTRAINT SQL into OpDropMultiColumnConstraint operatio…
…ns (#536) Convert `DROP CONSTRAINT SQL` into an `OpDropMultiColumnConstraint`. Because we are unable to infer the columns involved, placeholder migrations are used. SQL statements like the following are supported: ```sql ALTER TABLE foo DROP CONSTRAINT constraint_foo ALTER TABLE foo DROP CONSTRAINT IF EXISTS constraint_foo ALTER TABLE foo DROP CONSTRAINT IF EXISTS constraint_foo RESTRICT ``` `CASCADE` is currently not supported and will fall back to raw SQL Part of #504
- Loading branch information
Showing
4 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package expect | ||
|
||
import ( | ||
"github.com/xataio/pgroll/pkg/migrations" | ||
"github.com/xataio/pgroll/pkg/sql2pgroll" | ||
) | ||
|
||
func OpDropConstraintWithTable(table string) *migrations.OpDropMultiColumnConstraint { | ||
return &migrations.OpDropMultiColumnConstraint{ | ||
Up: migrations.MultiColumnUpSQL{ | ||
"placeholder": sql2pgroll.PlaceHolderSQL, | ||
}, | ||
Down: migrations.MultiColumnDownSQL{ | ||
"placeholder": sql2pgroll.PlaceHolderSQL, | ||
}, | ||
Table: table, | ||
Name: "constraint_foo", | ||
} | ||
} |