pgSuite.addNotNullWithDataNoRollback() — drizzle-orm Function Reference
Architecture documentation for the pgSuite.addNotNullWithDataNoRollback() function in pg.test.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 34559e51_2016_8a5b_10f9_8bbe54dd81e0["pgSuite.addNotNullWithDataNoRollback()"] 0408ab8f_6d6f_cdae_29f3_25c8efadbfae["pg.test.ts"] 34559e51_2016_8a5b_10f9_8bbe54dd81e0 -->|defined in| 0408ab8f_6d6f_cdae_29f3_25c8efadbfae style 34559e51_2016_8a5b_10f9_8bbe54dd81e0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/tests/push/pg.test.ts lines 841–916
async addNotNullWithDataNoRollback() {
const client = new PGlite();
const db = drizzle(client);
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[];
};
await db.insert(schema1.users).values({ id: 'str', email: 'email@gmail' });
const { statementsToExecute, shouldAskForApprove } = await pgSuggestions({ query }, statements);
expect(statementsToExecute).toStrictEqual(['ALTER TABLE "User" ALTER COLUMN "email" SET NOT NULL;']);
expect(shouldAskForApprove).toBeFalsy();
},
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does pgSuite.addNotNullWithDataNoRollback() do?
pgSuite.addNotNullWithDataNoRollback() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/push/pg.test.ts.
Where is pgSuite.addNotNullWithDataNoRollback() defined?
pgSuite.addNotNullWithDataNoRollback() is defined in drizzle-kit/tests/push/pg.test.ts at line 841.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free