Skip to content

Commit 72b7402

Browse files
Update documentation
1 parent 11bd834 commit 72b7402

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ Example **create table** migrations:
11011101

11021102
A create constraint operation adds a new constraint to an existing table.
11031103

1104-
Only `UNIQUE` and `CHECK` constraints are supported.
1104+
`UNIQUE`, `CHECK` and `FOREIGN KEY` constraints are supported.
11051105

11061106
Required fields: `name`, `table`, `type`, `up`, `down`.
11071107

@@ -1113,7 +1113,14 @@ Required fields: `name`, `table`, `type`, `up`, `down`.
11131113
"table": "name of table",
11141114
"name": "my_unique_constraint",
11151115
"columns": ["col1", "col2"],
1116-
"type": "unique"
1116+
"type": "unique"| "check" | "foreign_key",
1117+
"check": "SQL expression for CHECK constraint",
1118+
"references": {
1119+
"name": "name of foreign key reference",
1120+
"table": "name of referenced table",
1121+
"columns": "[names of referenced columns]",
1122+
"on_delete": "ON DELETE behaviour, can be CASCADE, SET NULL, RESTRICT, or NO ACTION. Default is NO ACTION",
1123+
},
11171124
"up": {
11181125
"col1": "col1 || random()",
11191126
"col2": "col2 || random()"
@@ -1130,7 +1137,7 @@ Example **create constraint** migrations:
11301137

11311138
* [44_add_table_unique_constraint.json](../examples/44_add_table_unique_constraint.json)
11321139
* [45_add_table_check_constraint.json](../examples/45_add_table_check_constraint.json)
1133-
1140+
* [46_add_table_foreign_key_constraint.json](../examples/46_add_table_foreign_key_constraint.json)
11341141

11351142
### Drop column
11361143

0 commit comments

Comments
 (0)