xataio/pgroll

Backfilling in tables with text valued primary keys is broken

Closed this issue · 0 comments

Backfills for tables with text valued PKs always fail.

To reproduce:

  1. Create a table with PK of type text:
{
  "name": "01_create_table",
  "operations": [
    {
      "create_table": {
        "name": "foo",
        "columns": [
          {
            "name": "id",
            "type": "text",
            "pk": true
          }
        ]
      }
    }
  ]
}
  1. Insert a row into the table
insert into foo(id) values (1)
  1. Try to add a column that requires a backfill:
{
  "name": "02_add_text_column",
  "operations": [
    {
      "add_column": {
        "table": "foo",
        "up": "id || '-description'",
        "column": {
          "name": "description",
          "type": "text",
          "nullable": false
        }
      }
    }
  ]
}

The migration fails with:

 ERROR   Failed to start migration: failed to backfill column: pq: operator does not exist: text > integer