@@ -1101,7 +1101,7 @@ Example **create table** migrations:
1101
1101
1102
1102
A create constraint operation adds a new constraint to an existing table.
1103
1103
1104
- Only ` UNIQUE ` and ` CHECK ` constraints are supported.
1104
+ ` UNIQUE ` , ` CHECK ` and ` FOREIGN KEY ` constraints are supported.
1105
1105
1106
1106
Required fields: ` name ` , ` table ` , ` type ` , ` up ` , ` down ` .
1107
1107
@@ -1113,7 +1113,14 @@ Required fields: `name`, `table`, `type`, `up`, `down`.
1113
1113
"table" : " name of table" ,
1114
1114
"name" : " my_unique_constraint" ,
1115
1115
"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
+ },
1117
1124
"up" : {
1118
1125
"col1" : " col1 || random()" ,
1119
1126
"col2" : " col2 || random()"
@@ -1130,7 +1137,7 @@ Example **create constraint** migrations:
1130
1137
1131
1138
* [ 44_add_table_unique_constraint.json] ( ../examples/44_add_table_unique_constraint.json )
1132
1139
* [ 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 )
1134
1141
1135
1142
### Drop column
1136
1143
0 commit comments