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

prepareMySqlCreateTableJson() — drizzle-orm Function Reference

Architecture documentation for the prepareMySqlCreateTableJson() function in jsonStatements.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  c8e94614_7790_e90e_5535_754d695bde57["prepareMySqlCreateTableJson()"]
  6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"]
  c8e94614_7790_e90e_5535_754d695bde57 -->|defined in| 6139f734_8ada_c641_9fec_9a55cfdf376f
  a5972ffc_ff1b_9523_2495_5373af710e65["applyMysqlSnapshotsDiff()"]
  a5972ffc_ff1b_9523_2495_5373af710e65 -->|calls| c8e94614_7790_e90e_5535_754d695bde57
  style c8e94614_7790_e90e_5535_754d695bde57 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/jsonStatements.ts lines 919–946

export const prepareMySqlCreateTableJson = (
	table: Table,
	// TODO: remove?
	json2: MySqlSchema,
	// we need it to know if some of the indexes(and in future other parts) are expressions or columns
	// didn't change mysqlserialaizer, because it will break snapshots and diffs and it's hard to detect
	// if previously it was an expression or column
	internals: MySqlKitInternals,
): JsonCreateTableStatement => {
	const { name, schema, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table;

	return {
		type: 'create_table',
		tableName: name,
		schema,
		columns: Object.values(columns),
		compositePKs: Object.values(compositePrimaryKeys),
		compositePkName: Object.values(compositePrimaryKeys).length > 0
			? json2.tables[name].compositePrimaryKeys[
				MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0])
					.name
			].name
			: '',
		uniqueConstraints: Object.values(uniqueConstraints),
		internals,
		checkConstraints: Object.values(checkConstraints),
	};
};

Domain

Subdomains

Frequently Asked Questions

What does prepareMySqlCreateTableJson() do?
prepareMySqlCreateTableJson() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/jsonStatements.ts.
Where is prepareMySqlCreateTableJson() defined?
prepareMySqlCreateTableJson() is defined in drizzle-kit/src/jsonStatements.ts at line 919.
What calls prepareMySqlCreateTableJson()?
prepareMySqlCreateTableJson() is called by 1 function(s): applyMysqlSnapshotsDiff.

Analyze Your Own Codebase

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

Try Supermodel Free