Home / Function/ pgSuite.addBasicIndexes() — drizzle-orm Function Reference

pgSuite.addBasicIndexes() — drizzle-orm Function Reference

Architecture documentation for the pgSuite.addBasicIndexes() function in pg.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  2ed6885c_4f9d_059f_556c_5ac7503f63a8["pgSuite.addBasicIndexes()"]
  0408ab8f_6d6f_cdae_29f3_25c8efadbfae["pg.test.ts"]
  2ed6885c_4f9d_059f_556c_5ac7503f63a8 -->|defined in| 0408ab8f_6d6f_cdae_29f3_25c8efadbfae
  style 2ed6885c_4f9d_059f_556c_5ac7503f63a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/tests/push/pg.test.ts lines 227–326

	async addBasicIndexes() {
		const client = new PGlite();

		const schema1 = {
			users: pgTable('users', {
				id: serial('id').primaryKey(),
				name: text('name'),
			}),
		};

		const schema2 = {
			users: pgTable(
				'users',
				{
					id: serial('id').primaryKey(),
					name: text('name'),
				},
				(t) => ({
					indx: index()
						.on(t.name.desc(), t.id.asc().nullsLast())
						.with({ fillfactor: 70 })
						.where(sql`select 1`),
					indx1: index('indx1')
						.using('hash', t.name.desc(), sql`${t.name}`)
						.with({ fillfactor: 70 }),
				}),
			),
		};

		const { statements, sqlStatements } = await diffTestSchemasPush(client, schema1, schema2, [], false, ['public']);
		expect(statements.length).toBe(2);
		expect(statements[0]).toStrictEqual({
			schema: '',
			tableName: 'users',
			type: 'create_index_pg',
			data: {
				columns: [
					{
						asc: false,
						expression: 'name',
						isExpression: false,
						nulls: 'last',
						opclass: undefined,
					},
					{
						asc: true,
						expression: 'id',
						isExpression: false,
						nulls: 'last',
						opclass: undefined,
					},
				],
				concurrently: false,
				isUnique: false,
				method: 'btree',
				name: 'users_name_id_index',
				where: 'select 1',
				with: {
					fillfactor: 70,
				},
			},
		});
		expect(statements[1]).toStrictEqual({
			schema: '',
			tableName: 'users',
			type: 'create_index_pg',
			data: {
				columns: [
					{
						asc: false,
						expression: 'name',
						isExpression: false,
						nulls: 'last',
						opclass: undefined,
					},
					{
						asc: true,
						expression: '"name"',
						isExpression: true,
						nulls: 'last',
					},

Domain

Subdomains

Frequently Asked Questions

What does pgSuite.addBasicIndexes() do?
pgSuite.addBasicIndexes() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/push/pg.test.ts.
Where is pgSuite.addBasicIndexes() defined?
pgSuite.addBasicIndexes() is defined in drizzle-kit/tests/push/pg.test.ts at line 227.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free