Commit Graph

2 Commits

Author SHA1 Message Date
Andrew Farries
eacb929840
Make index name mandatory on create index operation (#59)
Make specifying a name mandatory on the **Create index** operation. 

In order to work with indexes in subsequent migrations (eg deleting the
index), the user will have to know the name of the migration. If the
migration name is auto-generated and we ever change how names are
generated, then we risk breaking a user's migrations if they have
migrations that refer to these generated names.
2023-08-18 08:55:25 +01:00
Andrew Farries
9b7409b587
Implement 'create index' migrations (#49)
Add support for **create index** migrations. A create index migration
looks like this:

```json
{
  "name": "10_create_index",
  "operations": [
    {
      "create_index": {
        "table": "fruits",
        "columns": [
          "name"
        ]
      }
    }
  ]
}
```
* On `Start` the index is added to the underlying table.
* On `Rollback` the index is removed from the underlying table.
* `Complete` is a no-op.

There are more options that could be supported here, but are not
included in this PR including:
* Different index types besides the default (btree)
* `UNIQUE`
* `NULLS FIRST / LAST`
* `NULLS DISTINCT`
* Partial indexes
2023-08-17 11:51:20 +01:00