xataio / pgroll

PostgreSQL zero-downtime migrations made easy

Home Page:https://www.xata.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alter column operations should allow specification of unchanged fields

andrew-farries opened this issue · comments

Alter column operations should support specifying fields that are unchanged as no-ops.

For example, this migration:

{
  "name": "35_alter_column_multiple",
  "operations": [
    {
      "alter_column": {
        "table": "events",
        "column": "name",
        "name": "event_name",
        "nullable": false,
        "up": "(SELECT CASE WHEN name IS NULL THEN 'placeholder' ELSE name END)",
        "down": "name"
      }
    }
  ]
}

Renames a field and sets it to NOT NULL. If the field is already NOT NULL, the operation should not perform any column duplication or backfilling to support setting the column nullability.