pgroll/examples/35_alter_column_multiple.json
Andrew Farries 4d3faebffd
Make down SQL in rename column operations use the new name of the column (#354)
Ensure that 'alter column' operations that rename a column and also
specify `down` SQL (such as those that alter some other column attribute
at the time of the rename) must use the new name of the column in the
`down` SQL.

Without this change, the `down` SQL would require the use of the old
column name.

Fixes #350
2024-05-16 11:57:53 +01:00

26 lines
649 B
JSON

{
"name": "35_alter_column_multiple",
"operations": [
{
"alter_column": {
"table": "events",
"column": "name",
"name": "event_name",
"type": "text",
"default": "'unknown event'",
"nullable": false,
"comment": "the full name of the event",
"unique": {
"name": "events_event_name_unique"
},
"check": {
"name": "event_name_length",
"constraint": "length(name) > 3"
},
"up": "(SELECT CASE WHEN name IS NULL OR LENGTH(name) <= 3 THEN 'placeholder' ELSE name END)",
"down": "event_name"
}
}
]
}