xataio / pgroll

PostgreSQL zero-downtime migrations made easy
https://www.xata.io
Apache License 2.0
2.97k stars 54 forks source link

Support multiple sub-operations in one 'alter column' migration #336

Closed andrew-farries closed 4 months ago

andrew-farries commented 5 months ago

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.