Home / File/ pg-identity.test.ts — drizzle-orm Source File

pg-identity.test.ts — drizzle-orm Source File

Architecture documentation for pg-identity.test.ts, a typescript file in the drizzle-orm codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  75f17f3b_de62_f09d_ce97_b01356c21c52["pg-identity.test.ts"]
  fb6b4a65_030b_ce6b_df0d_2be21adcd2b3["schemaDiffer.ts"]
  75f17f3b_de62_f09d_ce97_b01356c21c52 --> fb6b4a65_030b_ce6b_df0d_2be21adcd2b3
  c00494ea_6230_22b6_9b91_d37781a8ac08["diffTestSchemas"]
  75f17f3b_de62_f09d_ce97_b01356c21c52 --> c00494ea_6230_22b6_9b91_d37781a8ac08
  53497908_16e7_977d_e97d_7414884a88a6["pg-core"]
  75f17f3b_de62_f09d_ce97_b01356c21c52 --> 53497908_16e7_977d_e97d_7414884a88a6
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  75f17f3b_de62_f09d_ce97_b01356c21c52 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style 75f17f3b_de62_f09d_ce97_b01356c21c52 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { integer, pgSequence, pgTable } from 'drizzle-orm/pg-core';
import { expect, test } from 'vitest';
import { diffTestSchemas } from './schemaDiffer';

// same table - no diff
// 2. identity always/by default - no params +
// 3. identity always/by default - with a few params +
// 4. identity always/by default - with all params +

// diff table with create statement
// 2. identity always/by default - no params +
// 3. identity always/by default - with a few params +
// 4. identity always/by default - with all params +

// diff for drop statement
// 2. identity always/by default - no params, with params +

// diff for alters
// 2. identity always/by default - no params -> add param +
// 3. identity always/by default - with a few params - remove/add/change params +
// 4. identity always/by default - with all params - remove/add/change params +

test('create table: identity always/by default - no params', async () => {
	const from = {};

	const to = {
		users: pgTable('users', {
			id: integer('id').generatedByDefaultAsIdentity(),
		}),
	};

	const { statements, sqlStatements } = await diffTestSchemas(from, to, []);

	expect(statements).toStrictEqual([
		{
			columns: [
				{
					identity: 'users_id_seq;byDefault;1;2147483647;1;1;1;false',
					name: 'id',
					notNull: true,
					primaryKey: false,
					type: 'integer',
				},
			],
			compositePKs: [],
			compositePkName: '',
			schema: '',
			policies: [],
			isRLSEnabled: false,
			tableName: 'users',
			type: 'create_table',
			uniqueConstraints: [],
			checkConstraints: [],
		},
	]);
	expect(sqlStatements).toStrictEqual([
		'CREATE TABLE "users" (\n\t"id" integer GENERATED BY DEFAULT AS IDENTITY (sequence name "users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1)\n);\n',
	]);
});

// ... (388 more lines)

Domain

Dependencies

Frequently Asked Questions

What does pg-identity.test.ts do?
pg-identity.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does pg-identity.test.ts depend on?
pg-identity.test.ts imports 4 module(s): diffTestSchemas, pg-core, schemaDiffer.ts, vitest.
Where is pg-identity.test.ts in the architecture?
pg-identity.test.ts is located at drizzle-kit/tests/pg-identity.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