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

prepareLibSQLRecreateTable() — drizzle-orm Function Reference

Architecture documentation for the prepareLibSQLRecreateTable() function in statementCombiner.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  02eb8e63_cc1f_ad01_411f_c75b81563b47["prepareLibSQLRecreateTable()"]
  21a395af_9564_2dbd_9ea9_060ad50ee7a0["statementCombiner.ts"]
  02eb8e63_cc1f_ad01_411f_c75b81563b47 -->|defined in| 21a395af_9564_2dbd_9ea9_060ad50ee7a0
  7185395a_8db7_95fd_888a_bc6d13893d75["libSQLCombineStatements()"]
  7185395a_8db7_95fd_888a_bc6d13893d75 -->|calls| 02eb8e63_cc1f_ad01_411f_c75b81563b47
  0848c4a3_d489_0afb_1396_c6648ea30e50["prepareCreateIndexesJson()"]
  02eb8e63_cc1f_ad01_411f_c75b81563b47 -->|calls| 0848c4a3_d489_0afb_1396_c6648ea30e50
  style 02eb8e63_cc1f_ad01_411f_c75b81563b47 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/statementCombiner.ts lines 10–41

export const prepareLibSQLRecreateTable = (
	table: SQLiteSchemaSquashed['tables'][keyof SQLiteSchemaSquashed['tables']],
	action?: 'push',
): (JsonRecreateTableStatement | JsonCreateIndexStatement)[] => {
	const { name, columns, uniqueConstraints, indexes, checkConstraints } = table;

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

	const references: string[] = Object.values(table.foreignKeys);
	const fks = references.map((it) =>
		action === 'push' ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
	);

	const statements: (JsonRecreateTableStatement | JsonCreateIndexStatement)[] = [
		{
			type: 'recreate_table',
			tableName: name,
			columns: Object.values(columns),
			compositePKs: composites,
			referenceData: fks,
			uniqueConstraints: Object.values(uniqueConstraints),
			checkConstraints: Object.values(checkConstraints),
		},
	];

	if (Object.keys(indexes).length) {
		statements.push(...prepareCreateIndexesJson(name, '', indexes));
	}
	return statements;
};

Domain

Subdomains

Frequently Asked Questions

What does prepareLibSQLRecreateTable() do?
prepareLibSQLRecreateTable() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/statementCombiner.ts.
Where is prepareLibSQLRecreateTable() defined?
prepareLibSQLRecreateTable() is defined in drizzle-kit/src/statementCombiner.ts at line 10.
What does prepareLibSQLRecreateTable() call?
prepareLibSQLRecreateTable() calls 1 function(s): prepareCreateIndexesJson.
What calls prepareLibSQLRecreateTable()?
prepareLibSQLRecreateTable() is called by 1 function(s): libSQLCombineStatements.

Analyze Your Own Codebase

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

Try Supermodel Free