MCPcopy
hub / github.com/drizzle-team/drizzle-orm / addBasicIndexes

Function addBasicIndexes

drizzle-kit/tests/push/pg.test.ts:227–326  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225 },
226
227 async addBasicIndexes() {
228 const client = new PGlite();
229
230 const schema1 = {
231 users: pgTable('users', {
232 id: serial('id').primaryKey(),
233 name: text('name'),
234 }),
235 };
236
237 const schema2 = {
238 users: pgTable(
239 'users',
240 {
241 id: serial('id').primaryKey(),
242 name: text('name'),
243 },
244 (t) => ({
245 indx: index()
246 .on(t.name.desc(), t.id.asc().nullsLast())
247 .with({ fillfactor: 70 })
248 .where(sql`select 1`),
249 indx1: index('indx1')
250 .using('hash', t.name.desc(), sql`${t.name}`)
251 .with({ fillfactor: 70 }),
252 }),
253 ),
254 };
255
256 const { statements, sqlStatements } = await diffTestSchemasPush(client, schema1, schema2, [], false, ['public']);
257 expect(statements.length).toBe(2);
258 expect(statements[0]).toStrictEqual({
259 schema: '',
260 tableName: 'users',
261 type: 'create_index_pg',
262 data: {
263 columns: [
264 {
265 asc: false,
266 expression: 'name',
267 isExpression: false,
268 nulls: 'last',
269 opclass: undefined,
270 },
271 {
272 asc: true,
273 expression: 'id',
274 isExpression: false,
275 nulls: 'last',
276 opclass: undefined,
277 },
278 ],
279 concurrently: false,
280 isUnique: false,
281 method: 'btree',
282 name: 'users_name_id_index',
283 where: 'select 1',
284 with: {

Callers

nothing calls this directly

Calls 13

pgTableFunction · 0.90
serialFunction · 0.90
textFunction · 0.90
indexFunction · 0.90
sqlFunction · 0.90
diffTestSchemasPushFunction · 0.90
whereMethod · 0.45
withMethod · 0.45
onMethod · 0.45
descMethod · 0.45
nullsLastMethod · 0.45
ascMethod · 0.45

Tested by

no test coverage detected