Home / Function/ createTableIndexes() — drizzle-orm Function Reference

createTableIndexes() — drizzle-orm Function Reference

Architecture documentation for the createTableIndexes() function in introspect-mysql.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  b0c2da4f_e69e_c657_1b9f_05841197cf08["createTableIndexes()"]
  1198bdc6_ac5c_88c0_dda6_b8caf0f5d9fa["introspect-mysql.ts"]
  b0c2da4f_e69e_c657_1b9f_05841197cf08 -->|defined in| 1198bdc6_ac5c_88c0_dda6_b8caf0f5d9fa
  194539cf_d577_ab5e_4ea9_ec2fd5ee230b["schemaToTypeScript()"]
  194539cf_d577_ab5e_4ea9_ec2fd5ee230b -->|calls| b0c2da4f_e69e_c657_1b9f_05841197cf08
  style b0c2da4f_e69e_c657_1b9f_05841197cf08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/introspect-mysql.ts lines 901–929

const createTableIndexes = (
	tableName: string,
	idxs: Index[],
	casing: (value: string) => string,
): string => {
	let statement = '';

	idxs.forEach((it) => {
		let idxKey = it.name.startsWith(tableName) && it.name !== tableName
			? it.name.slice(tableName.length + 1)
			: it.name;
		idxKey = idxKey.endsWith('_index')
			? idxKey.slice(0, -'_index'.length) + '_idx'
			: idxKey;

		idxKey = casing(idxKey);

		statement += `\n\t`;
		statement += it.isUnique ? 'uniqueIndex(' : 'index(';
		statement += `"${it.name}")`;
		statement += `.on(${
			it.columns
				.map((it) => `table.${casing(it)}`)
				.join(', ')
		}),`;
	});

	return statement;
};

Domain

Subdomains

Frequently Asked Questions

What does createTableIndexes() do?
createTableIndexes() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-mysql.ts.
Where is createTableIndexes() defined?
createTableIndexes() is defined in drizzle-kit/src/introspect-mysql.ts at line 901.
What calls createTableIndexes()?
createTableIndexes() is called by 1 function(s): schemaToTypeScript.

Analyze Your Own Codebase

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

Try Supermodel Free