Skip to content

Commit ea8b295

Browse files
authored
Remove instances of deprecated third param in table definition (#480)
1 parent 581ce43 commit ea8b295

22 files changed

+240
-309
lines changed

src/content/docs/extensions/pg.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Let's take a few examples of `pg_vector` indexes from the `pg_vector` docs and t
5858

5959
const table = pgTable('items', {
6060
embedding: vector({ dimensions: 3 })
61-
}, (table) => ({
62-
l2: index('l2_index').using('hnsw', table.embedding.op('vector_l2_ops'))
63-
ip: index('ip_index').using('hnsw', table.embedding.op('vector_ip_ops'))
64-
cosine: index('cosine_index').using('hnsw', table.embedding.op('vector_cosine_ops'))
65-
}))
61+
}, (table) => [
62+
index('l2_index').using('hnsw', table.embedding.op('vector_l2_ops'))
63+
index('ip_index').using('hnsw', table.embedding.op('vector_ip_ops'))
64+
index('cosine_index').using('hnsw', table.embedding.op('vector_cosine_ops'))
65+
])
6666
```
6767

6868
#### L1 distance, Hamming distance and Jaccard distance - added in pg_vector 0.7.0 version
@@ -74,11 +74,11 @@ const table = pgTable('items', {
7474

7575
const table = pgTable('table', {
7676
embedding: vector({ dimensions: 3 })
77-
}, (table) => ({
78-
l1: index('l1_index').using('hnsw', table.embedding.op('vector_l1_ops'))
79-
hamming: index('hamming_index').using('hnsw', table.embedding.op('bit_hamming_ops'))
80-
bit: index('bit_jaccard_index').using('hnsw', table.embedding.op('bit_jaccard_ops'))
81-
}))
77+
}, (table) => [
78+
index('l1_index').using('hnsw', table.embedding.op('vector_l1_ops'))
79+
index('hamming_index').using('hnsw', table.embedding.op('bit_hamming_ops'))
80+
index('bit_jaccard_index').using('hnsw', table.embedding.op('bit_jaccard_ops'))
81+
])
8282
```
8383

8484
#### Helper Functions
@@ -192,7 +192,7 @@ With the available Drizzle indexes API, you should be able to write any indexes
192192

193193
const table = pgTable('table', {
194194
geo: geometry({ type: 'point' }),
195-
}, (table) => ({
196-
gist: index('custom_idx').using('gist', table.geo)
197-
}))
195+
}, (table) => [
196+
index('custom_idx').using('gist', table.geo)
197+
])
198198
```

src/content/docs/generated-columns.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ Generated columns can be especially useful for:
127127
(): SQL => sql`to_tsvector('english', ${test.content})`
128128
),
129129
},
130-
(t) => ({
131-
idx: index("idx_content_search").using("gin", t.contentSearch),
132-
})
130+
(t) => [
131+
index("idx_content_search").using("gin", t.contentSearch)
132+
]
133133
);
134134
```
135135
```sql {4}

src/content/docs/guides/cursor-based-pagination.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,12 @@ Make sure to create indices for the columns that you use for cursor to make quer
203203
import { index, ...imports } from 'drizzle-orm/pg-core';
204204

205205
export const users = pgTable('users', {
206-
// columns declaration
206+
// columns declaration
207207
},
208-
(t) => ({
209-
firstNameIndex: index('first_name_index').on(t.firstName).asc(),
210-
firstNameAndIdIndex: index('first_name_and_id_index').on(t.firstName, t.id).asc(),
211-
}),
212-
);
208+
(t) => [
209+
index('first_name_index').on(t.firstName).asc(),
210+
index('first_name_and_id_index').on(t.firstName, t.id).asc(),
211+
]);
213212
```
214213

215214
```sql

src/content/docs/guides/postgis-geometry-point.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ This is how you can create table with `geometry` datatype and spatial index in D
4444
name: text('name').notNull(),
4545
location: geometry('location', { type: 'point', mode: 'xy', srid: 4326 }).notNull(),
4646
},
47-
(t) => ({
48-
spatialIndex: index('spatial_index').using('gist', t.location),
49-
}),
47+
(t) => [
48+
index('spatial_index').using('gist', t.location),
49+
]
5050
);
5151
```
5252
</CodeTab>

src/content/docs/guides/postgresql-full-text-search.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ As for now, Drizzle doesn't support `tsvector` type natively, so you need to con
6969
id: serial('id').primaryKey(),
7070
title: text('title').notNull(),
7171
},
72-
(table) => ({
73-
titleSearchIndex: index('title_search_index')
74-
.using('gin', sql`to_tsvector('english', ${table.title})`),
75-
}),
72+
(table) => [
73+
index('title_search_index').using('gin', sql`to_tsvector('english', ${table.title})`),
74+
]
7675
);
7776
```
7877
</CodeTab>
@@ -235,15 +234,15 @@ To implement full-text search on multiple columns, you can create index on multi
235234
title: text('title').notNull(),
236235
description: text('description').notNull(),
237236
},
238-
(table) => ({
239-
searchIndex: index('search_index').using(
237+
(table) => [
238+
index('search_index').using(
240239
'gin',
241240
sql`(
242241
setweight(to_tsvector('english', ${table.title}), 'A') ||
243242
setweight(to_tsvector('english', ${table.description}), 'B')
244243
)`,
245244
),
246-
}),
245+
],
247246
);
248247
```
249248
</CodeTab>

src/content/docs/guides/unique-case-insensitive-email.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ Drizzle has simple and flexible API, which lets you easily create such an index
3535
name: text('name').notNull(),
3636
email: text('email').notNull(),
3737
},
38-
(table) => ({
39-
// emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
40-
emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(lower(table.email)),
41-
}),
38+
(table) => [
39+
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
40+
uniqueIndex('emailUniqueIndex').on(lower(table.email)),
41+
],
4242
);
4343

4444
// custom lower function
@@ -98,10 +98,10 @@ Drizzle has simple and flexible API, which lets you easily create such an index
9898
name: varchar('name', { length: 255 }).notNull(),
9999
email: varchar('email', { length: 255 }).notNull(),
100100
},
101-
(table) => ({
102-
// emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(sql`(lower(${table.email}))`),
103-
emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(lower(table.email)),
104-
}),
101+
(table) => [
102+
// uniqueIndex('emailUniqueIndex').on(sql`(lower(${table.email}))`),
103+
uniqueIndex('emailUniqueIndex').on(lower(table.email)),
104+
]
105105
);
106106

107107
// custom lower function
@@ -166,10 +166,10 @@ Drizzle has simple and flexible API, which lets you easily create such an index
166166
name: text('name').notNull(),
167167
email: text('email').notNull(),
168168
},
169-
(table) => ({
170-
// emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
171-
emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(lower(table.email)),
172-
}),
169+
(table) => [
170+
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
171+
uniqueIndex('emailUniqueIndex').on(lower(table.email)),
172+
]
173173
);
174174

175175
// custom lower function

src/content/docs/guides/vector-similarity-search.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ To perform similarity search, you need to create a table with a vector column an
5454
url: text('url').notNull(),
5555
embedding: vector('embedding', { dimensions: 1536 }),
5656
},
57-
(table) => ({
58-
embeddingIndex: index('embeddingIndex').using('hnsw', table.embedding.op('vector_cosine_ops')),
59-
}),
57+
(table) => [
58+
index('embeddingIndex').using('hnsw', table.embedding.op('vector_cosine_ops')),
59+
]
6060
);
6161
```
6262
</CodeTab>

0 commit comments

Comments
 (0)