You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alter column operations currently support only one 'sub-operation' at a time. So, for example, changing a column's name and setting it NOT NULL within the same operation is not supported:
{
"name": "35_alter_column_multiple",
"operations": [
{
"alter_column": {
"table": "events",
"column": "name",
"name": "username",
"nullable": false,
"up": "(SELECT CASE WHEN name IS NULL THEN 'placeholder' ELSE name END)"
}
}
]
}
This migration will fail with:
alter column operations require exactly one change, found 2
Alter column operations should change to allow more than one sub-operation at at time.
The text was updated successfully, but these errors were encountered:
Remove duplication between 'alter column' sub-operations. Pull:
* column duplication and trigger creation on migration start
* column rename and trigger removal on complete
* trigger and column drop on rollback
up to the parent 'alter column' operation. This removes a lot of
duplicated code from the sub-operations and will make it easier to
support multiple sub-operations in one 'alter column' operation.
Part of #336
Allow 'alter column' operations to include multiple sub-operations. This
means migrations like this one are now possible:
```json
{
"name": "35_alter_column_multiple",
"operations": [
{
"alter_column": {
"table": "events",
"column": "name",
"name": "event_name",
"type": "text",
"nullable": false,
"unique": {
"name": "events_event_name_unique"
},
"check": {
"name": "event_name_length",
"constraint": "length(name) > 3"
},
"up": "(SELECT CASE WHEN name IS NULL THEN 'placeholder' ELSE name END)",
"down": "name"
}
}
]
}
```
This 'alter column' operation:
* Renames a column
* Changes its type
* Sets it `NOT NULL`
* Adds a unique constraint
* Adds a check constraint
Previously, this would have required 5 different operations.
Builds on #337. Fixes#336
Alter column operations currently support only one 'sub-operation' at a time. So, for example, changing a column's name and setting it
NOT NULL
within the same operation is not supported:This migration will fail with:
Alter column operations should change to allow more than one sub-operation at at time.
The text was updated successfully, but these errors were encountered: