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

prepareSQLiteCreateTable() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  abc17f0b_61ac_9780_a8bf_8c398e388073["prepareSQLiteCreateTable()"]
  6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"]
  abc17f0b_61ac_9780_a8bf_8c398e388073 -->|defined in| 6139f734_8ada_c641_9fec_9a55cfdf376f
  d9097b7e_1e27_d29f_7732_f2fa1447f2b8["applySqliteSnapshotsDiff()"]
  d9097b7e_1e27_d29f_7732_f2fa1447f2b8 -->|calls| abc17f0b_61ac_9780_a8bf_8c398e388073
  55569cde_7638_9cfc_9dcd_34636d975ec3["applyLibSQLSnapshotsDiff()"]
  55569cde_7638_9cfc_9dcd_34636d975ec3 -->|calls| abc17f0b_61ac_9780_a8bf_8c398e388073
  style abc17f0b_61ac_9780_a8bf_8c398e388073 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/jsonStatements.ts lines 976–1003

export const prepareSQLiteCreateTable = (
	table: Table,
	action?: 'push' | undefined,
): JsonSqliteCreateTableStatement => {
	const { name, columns, uniqueConstraints, checkConstraints } = table;

	const references: string[] = Object.values(table.foreignKeys);

	const composites: string[][] = Object.values(table.compositePrimaryKeys).map(
		(it) => SQLiteSquasher.unsquashPK(it),
	);

	const fks = references.map((it) =>
		action === 'push'
			? SQLiteSquasher.unsquashPushFK(it)
			: SQLiteSquasher.unsquashFK(it)
	);

	return {
		type: 'sqlite_create_table',
		tableName: name,
		columns: Object.values(columns),
		referenceData: fks,
		compositePKs: composites,
		uniqueConstraints: Object.values(uniqueConstraints),
		checkConstraints: Object.values(checkConstraints),
	};
};

Domain

Subdomains

Frequently Asked Questions

What does prepareSQLiteCreateTable() do?
prepareSQLiteCreateTable() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/jsonStatements.ts.
Where is prepareSQLiteCreateTable() defined?
prepareSQLiteCreateTable() is defined in drizzle-kit/src/jsonStatements.ts at line 976.
What calls prepareSQLiteCreateTable()?
prepareSQLiteCreateTable() is called by 2 function(s): applyLibSQLSnapshotsDiff, applySqliteSnapshotsDiff.

Analyze Your Own Codebase

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

Try Supermodel Free