-
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.
Add support for creating foreign key constraints using `create_constr…
…aint` (#471) This PR introduces a new constraint `type` to `create_constraint` operation called `foreign_key`. Now it is possible to create FK constraints on multiple columns. ### Examples #### Foreign key ```json { "name": "44_add_foreign_key_table_reference_constraint", "operations": [ { "create_constraint": { "type": "foreign_key", "table": "tickets", "name": "fk_sellers", "columns": [ "sellers_name", "sellers_zip" ], "references": { "table": "sellers", "columns": [ "name", "zip" ], "on_delete": "CASCADE" }, "up": { "sellers_name": "sellers_name", "sellers_zip": "sellers_zip" }, "down": { "sellers_name": "sellers_name", "sellers_zip": "sellers_zip" } } } ] } ``` Closes #81 --------- Co-authored-by: Andrew Farries <[email protected]>
- Loading branch information
1 parent
81dd0a7
commit a9b2048
Showing
13 changed files
with
420 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "47_add_table_foreign_key_constraint", | ||
"operations": [ | ||
{ | ||
"create_constraint": { | ||
"type": "foreign_key", | ||
"table": "tickets", | ||
"name": "fk_sellers", | ||
"columns": [ | ||
"sellers_name", | ||
"sellers_zip" | ||
], | ||
"references": { | ||
"table": "sellers", | ||
"columns": [ | ||
"name", | ||
"zip" | ||
] | ||
}, | ||
"up": { | ||
"sellers_name": "sellers_name", | ||
"sellers_zip": "sellers_zip" | ||
}, | ||
"down": { | ||
"sellers_name": "sellers_name", | ||
"sellers_zip": "sellers_zip" | ||
} | ||
} | ||
} | ||
] | ||
} |
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
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
Oops, something went wrong.