mirror of
https://github.com/xataio/pgroll.git
synced 2024-08-16 09:10:26 +03:00
4d3faebffd
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
26 lines
649 B
JSON
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"
|
|
}
|
|
}
|
|
]
|
|
}
|