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

pgSuite.addNotNull() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

drizzle-kit/tests/push/pg.test.ts lines 769–839

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

		const schema1 = {
			users: pgTable(
				'User',
				{
					id: text('id').primaryKey().notNull(),
					name: text('name'),
					username: text('username'),
					gh_username: text('gh_username'),
					email: text('email'),
					emailVerified: timestamp('emailVerified', {
						precision: 3,
						mode: 'date',
					}),
					image: text('image'),
					createdAt: timestamp('createdAt', { precision: 3, mode: 'date' })
						.default(sql`CURRENT_TIMESTAMP`)
						.notNull(),
					updatedAt: timestamp('updatedAt', { precision: 3, mode: 'date' })
						.notNull()
						.$onUpdate(() => new Date()),
				},
				(table) => {
					return {
						emailKey: uniqueIndex('User_email_key').on(table.email),
					};
				},
			),
		};

		const schema2 = {
			users: pgTable(
				'User',
				{
					id: text('id').primaryKey().notNull(),
					name: text('name'),
					username: text('username'),
					gh_username: text('gh_username'),
					email: text('email').notNull(),
					emailVerified: timestamp('emailVerified', {
						precision: 3,
						mode: 'date',
					}),
					image: text('image'),
					createdAt: timestamp('createdAt', { precision: 3, mode: 'date' })
						.default(sql`CURRENT_TIMESTAMP`)
						.notNull(),
					updatedAt: timestamp('updatedAt', { precision: 3, mode: 'date' })
						.notNull()
						.$onUpdate(() => new Date()),
				},
				(table) => {
					return {
						emailKey: uniqueIndex('User_email_key').on(table.email),
					};
				},
			),
		};

		const { statements, sqlStatements } = await diffTestSchemasPush(client, schema1, schema2, [], false, ['public']);
		const query = async (sql: string, params?: any[]) => {
			const result = await client.query(sql, params ?? []);
			return result.rows as any[];
		};

		const { statementsToExecute } = await pgSuggestions({ query }, statements);

		expect(statementsToExecute).toStrictEqual(['ALTER TABLE "User" ALTER COLUMN "email" SET NOT NULL;']);
	},

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free