mirror of
https://github.com/xataio/pgroll.git
synced 2024-07-14 17:10:33 +03:00
0c7ecf2887
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).
18 lines
387 B
JSON
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"
|
|
}
|
|
}
|
|
]
|
|
}
|