summaryrefslogtreecommitdiff
path: root/.changeset/blue-ghosts-rule.md
blob: ea06089c6c69494f6e8d821599ac2ab27e00ffbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
"@astrojs/db": patch
---

Update the table indexes configuration to allow generated index names. The `indexes` object syntax is now deprecated in favor of an array.

## Migration

You can update your `indexes` configuration object to an array like so:

```diff
import { defineDb, defineTable, column } from 'astro:db';

const Comment = defineTable({
  columns: {
    postId: column.number(),
    author: column.text(),
    body: column.text(),
  },
- indexes: {
-   postIdIdx: { on: 'postId' },
-   authorPostIdIdx: { on: ['author, postId'], unique: true },
- },
+ indexes: [
+   { on: 'postId' /* 'name' is optional */ },
+   { on: ['author, postId'], unique: true },
+ ]
})
```

This example will generate indexes with the names `Comment_postId_idx` and `Comment_author_postId_idx`, respectively. You can specify a name manually by adding the `name` attribute to a given object. This name will be **global,** so ensure index names do not conflict between tables.