pg-checks.test.ts — drizzle-orm Source File
Architecture documentation for pg-checks.test.ts, a typescript file in the drizzle-orm codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 72f44a89_fc01_9b08_d6bb_a08b8d8cae10["pg-checks.test.ts"] fb6b4a65_030b_ce6b_df0d_2be21adcd2b3["schemaDiffer.ts"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> fb6b4a65_030b_ce6b_df0d_2be21adcd2b3 c00494ea_6230_22b6_9b91_d37781a8ac08["diffTestSchemas"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> c00494ea_6230_22b6_9b91_d37781a8ac08 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 53497908_16e7_977d_e97d_7414884a88a6["pg-core"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> 53497908_16e7_977d_e97d_7414884a88a6 76cb6b0b_4692_581e_e6e4_769d23792713["jsonStatements"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> 76cb6b0b_4692_581e_e6e4_769d23792713 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 style 72f44a89_fc01_9b08_d6bb_a08b8d8cae10 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { sql } from 'drizzle-orm';
import { check, integer, pgTable, serial, varchar } from 'drizzle-orm/pg-core';
import { JsonCreateTableStatement } from 'src/jsonStatements';
import { expect, test } from 'vitest';
import { diffTestSchemas } from './schemaDiffer';
test('create table with check', async (t) => {
const to = {
users: pgTable('users', {
id: serial('id').primaryKey(),
age: integer('age'),
}, (table) => ({
checkConstraint: check('some_check_name', sql`${table.age} > 21`),
})),
};
const { sqlStatements, statements } = await diffTestSchemas({}, to, []);
expect(statements.length).toBe(1);
expect(statements[0]).toStrictEqual({
type: 'create_table',
tableName: 'users',
schema: '',
columns: [
{
name: 'id',
type: 'serial',
notNull: true,
primaryKey: true,
},
{
name: 'age',
type: 'integer',
notNull: false,
primaryKey: false,
},
],
compositePKs: [],
checkConstraints: ['some_check_name;"users"."age" > 21'],
compositePkName: '',
uniqueConstraints: [],
isRLSEnabled: false,
policies: [],
} as JsonCreateTableStatement);
expect(sqlStatements.length).toBe(1);
expect(sqlStatements[0]).toBe(`CREATE TABLE "users" (
\t"id" serial PRIMARY KEY NOT NULL,
\t"age" integer,
\tCONSTRAINT "some_check_name" CHECK ("users"."age" > 21)
);\n`);
});
test('add check contraint to existing table', async (t) => {
const from = {
users: pgTable('users', {
id: serial('id').primaryKey(),
age: integer('age'),
}),
};
// ... (223 more lines)
Domain
Dependencies
- diffTestSchemas
- drizzle-orm
- jsonStatements
- pg-core
- schemaDiffer.ts
- vitest
Source
Frequently Asked Questions
What does pg-checks.test.ts do?
pg-checks.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does pg-checks.test.ts depend on?
pg-checks.test.ts imports 6 module(s): diffTestSchemas, drizzle-orm, jsonStatements, pg-core, schemaDiffer.ts, vitest.
Where is pg-checks.test.ts in the architecture?
pg-checks.test.ts is located at drizzle-kit/tests/pg-checks.test.ts (domain: DrizzleORM, directory: drizzle-kit/tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free