Check constraints
Check constraints are changed from inside altertable with three keys: add_check, modify_check and drop_check.
A check constraint takes a name and a condition. See Conditions for the condition format.
Add check constraint
add_check takes an array of check constraints.
{
"altertable": {
"events": {
"add_check": [
{
"name": "events_valid_time",
"condition": {
"type": "comparison",
"op": ">",
"left": { "type": "column", "name": "end_at" },
"right": { "type": "column", "name": "start_at" }
}
}
]
}
}
}Modify check constraint
modify_check has the same shape as add_check. Because a constraint cannot be changed in place, it is compiled to a drop of the existing constraint (by name) followed by adding it again with the new definition.
{
"altertable": {
"events": {
"modify_check": [
{
"name": "events_valid_time",
"condition": {
"type": "comparison",
"op": ">=",
"left": { "type": "column", "name": "end_at" },
"right": { "type": "column", "name": "start_at" }
}
}
]
}
}
}Drop check constraint
drop_check takes an array of constraint names.
{
"altertable": {
"events": {
"drop_check": ["events_valid_time"]
}
}
}Last updated on