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

pgSuite.addGeneratedToColumn() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

drizzle-kit/tests/push/pg.test.ts lines 375–423

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

		const schema1 = {
			users: pgTable('users', {
				id: integer('id'),
				id2: integer('id2'),
				name: text('name'),
				generatedName: text('gen_name'),
			}),
		};
		const schema2 = {
			users: pgTable('users', {
				id: integer('id'),
				id2: integer('id2'),
				name: text('name'),
				generatedName: text('gen_name').generatedAlwaysAs((): SQL => sql`${schema2.users.name}`),
			}),
		};

		const { statements, sqlStatements } = await diffTestSchemasPush(client, schema1, schema2, [], false, ['public']);

		expect(statements).toStrictEqual([
			{
				columnAutoIncrement: undefined,
				columnDefault: undefined,
				columnGenerated: {
					as: '"users"."name"',
					type: 'stored',
				},
				columnName: 'gen_name',
				columnNotNull: false,
				columnOnUpdate: undefined,
				columnPk: false,
				newDataType: 'text',
				schema: '',
				tableName: 'users',
				type: 'alter_table_alter_column_set_generated',
			},
		]);
		expect(sqlStatements).toStrictEqual([
			'ALTER TABLE "users" drop column "gen_name";',
			'ALTER TABLE "users" ADD COLUMN "gen_name" text GENERATED ALWAYS AS ("users"."name") STORED;',
		]);

		// for (const st of sqlStatements) {
		//   await client.query(st);
		// }
	},

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free