Home / Function/ mysqlSuite.createCompositePrimaryKey() — drizzle-orm Function Reference

mysqlSuite.createCompositePrimaryKey() — drizzle-orm Function Reference

Architecture documentation for the mysqlSuite.createCompositePrimaryKey() function in mysql.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  1825e2fe_d16f_10a2_4e76_2780d89c9af1["mysqlSuite.createCompositePrimaryKey()"]
  e4016db2_352d_b236_2557_d9a74c6066c1["mysql.test.ts"]
  1825e2fe_d16f_10a2_4e76_2780d89c9af1 -->|defined in| e4016db2_352d_b236_2557_d9a74c6066c1
  style 1825e2fe_d16f_10a2_4e76_2780d89c9af1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/tests/push/mysql.test.ts lines 667–712

	createCompositePrimaryKey: async function(context: any): Promise<void> {
		const schema1 = {};

		const schema2 = {
			table: mysqlTable('table', {
				col1: int('col1').notNull(),
				col2: int('col2').notNull(),
			}, (t) => ({
				pk: primaryKey({
					columns: [t.col1, t.col2],
				}),
			})),
		};

		const { statements, sqlStatements } = await diffTestSchemasPushMysql(
			context.client as Connection,
			schema1,
			schema2,
			[],
			'drizzle',
			false,
		);

		expect(statements).toStrictEqual([
			{
				type: 'create_table',
				tableName: 'table',
				schema: undefined,
				internals: {
					indexes: {},
					tables: {},
				},
				compositePKs: ['table_col1_col2_pk;col1,col2'],
				compositePkName: 'table_col1_col2_pk',
				uniqueConstraints: [],
				checkConstraints: [],
				columns: [
					{ name: 'col1', type: 'int', primaryKey: false, notNull: true, autoincrement: false },
					{ name: 'col2', type: 'int', primaryKey: false, notNull: true, autoincrement: false },
				],
			},
		]);
		expect(sqlStatements).toStrictEqual([
			'CREATE TABLE `table` (\n\t`col1` int NOT NULL,\n\t`col2` int NOT NULL,\n\tCONSTRAINT `table_col1_col2_pk` PRIMARY KEY(`col1`,`col2`)\n);\n',
		]);
	},

Domain

Subdomains

Frequently Asked Questions

What does mysqlSuite.createCompositePrimaryKey() do?
mysqlSuite.createCompositePrimaryKey() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/push/mysql.test.ts.
Where is mysqlSuite.createCompositePrimaryKey() defined?
mysqlSuite.createCompositePrimaryKey() is defined in drizzle-kit/tests/push/mysql.test.ts at line 667.

Analyze Your Own Codebase

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

Try Supermodel Free