mirror of
https://github.com/xataio/pgroll.git
synced 2024-10-26 05:46:27 +03:00
c1b8c65dd5
Make it required to supply a name for the `CHECK` constraint when adding one with the `set_check_constraint` operation. It should be possible to drop constraints with a later migration (not yet implemented), so requiring a name and not relying on automatic generation of constraint names will make this easier. The same thing was done for indexes in https://github.com/xataio/pg-roll/pull/59
16 lines
360 B
JSON
16 lines
360 B
JSON
{
|
|
"name": "22_add_check_constraint",
|
|
"operations": [
|
|
{
|
|
"alter_column": {
|
|
"table": "posts",
|
|
"column": "title",
|
|
"constraint_name": "title_length",
|
|
"check": "length(title) > 3",
|
|
"up": "(SELECT CASE WHEN length(title) <= 3 THEN LPAD(title, 4, '-') ELSE title END)",
|
|
"down": "title"
|
|
}
|
|
}
|
|
]
|
|
}
|