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

pgSuite.addGeneratedColumn() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

drizzle-kit/tests/push/pg.test.ts lines 328–373

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

		const schema1 = {
			users: pgTable('users', {
				id: integer('id'),
				id2: integer('id2'),
				name: text('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([
			{
				column: {
					generated: {
						as: '"users"."name"',
						type: 'stored',
					},
					name: 'gen_name',
					notNull: false,
					primaryKey: false,
					type: 'text',
				},
				schema: '',
				tableName: 'users',
				type: 'alter_table_add_column',
			},
		]);
		expect(sqlStatements).toStrictEqual([
			'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.addGeneratedColumn() do?
pgSuite.addGeneratedColumn() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/push/pg.test.ts.
Where is pgSuite.addGeneratedColumn() defined?
pgSuite.addGeneratedColumn() is defined in drizzle-kit/tests/push/pg.test.ts at line 328.

Analyze Your Own Codebase

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

Try Supermodel Free