pgroll/examples/22_add_check_constraint.json
Andrew Farries 0c7ecf2887
Move constraint name and expression into a new CheckConstraint struct (#107)
Move the `ConstraintName` and `Check` `string` fields on an
`alter_column` operation into a new `CheckConstraint` struct and make
validation a method on that new struct.

This is to facilitate being able to create tables and columns with
`CHECK` constraints in later PRs (#108, #109).
2023-09-19 10:49:40 +01:00

18 lines
387 B
JSON

{
"name": "22_add_check_constraint",
"operations": [
{
"alter_column": {
"table": "posts",
"column": "title",
"check": {
"name": "title_length",
"constraint": "length(title) > 3"
},
"up": "(SELECT CASE WHEN length(title) <= 3 THEN LPAD(title, 4, '-') ELSE title END)",
"down": "title"
}
}
]
}