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

singlestorePush() — drizzle-orm Function Reference

Architecture documentation for the singlestorePush() function in push.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  7a06eeb3_bb02_056b_baf7_97590f690573["singlestorePush()"]
  6219550e_1686_ca7a_0d96_0838fb90e7cb["push.ts"]
  7a06eeb3_bb02_056b_baf7_97590f690573 -->|defined in| 6219550e_1686_ca7a_0d96_0838fb90e7cb
  a6191ddf_c119_718d_8adb_1cf1f8e385b3["render()"]
  7a06eeb3_bb02_056b_baf7_97590f690573 -->|calls| a6191ddf_c119_718d_8adb_1cf1f8e385b3
  style 7a06eeb3_bb02_056b_baf7_97590f690573 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/cli/commands/push.ts lines 166–287

export const singlestorePush = async (
	schemaPath: string | string[],
	credentials: SingleStoreCredentials,
	tablesFilter: string[],
	strict: boolean,
	verbose: boolean,
	force: boolean,
	casing: CasingType | undefined,
) => {
	const { connectToSingleStore } = await import('../connections');
	const { singlestorePushIntrospect } = await import('./singlestoreIntrospect');

	const { db, database } = await connectToSingleStore(credentials);

	const { schema } = await singlestorePushIntrospect(
		db,
		database,
		tablesFilter,
	);
	const { prepareSingleStorePush } = await import('./migrate');

	const statements = await prepareSingleStorePush(schemaPath, schema, casing);

	const filteredStatements = singleStoreFilterStatements(
		statements.statements ?? [],
		statements.validatedCur,
		statements.validatedPrev,
	);

	try {
		if (filteredStatements.length === 0) {
			render(`[${chalk.blue('i')}] No changes detected`);
		} else {
			const {
				shouldAskForApprove,
				statementsToExecute,
				columnsToRemove,
				tablesToRemove,
				tablesToTruncate,
				infoToPrint,
				schemasToRemove,
			} = await singleStoreLogSuggestionsAndReturn(
				db,
				filteredStatements,
				statements.validatedCur,
				statements.validatedPrev,
			);

			if (verbose) {
				console.log();
				console.log(
					withStyle.warning('You are about to execute current statements:'),
				);
				console.log();
				console.log(statementsToExecute.map((s) => chalk.blue(s)).join('\n'));
				console.log();
			}

			if (!force && strict) {
				if (!shouldAskForApprove) {
					const { status, data } = await render(
						new Select(['No, abort', `Yes, I want to execute all statements`]),
					);
					if (data?.index === 0) {
						render(`[${chalk.red('x')}] All changes were aborted`);
						process.exit(0);
					}
				}
			}

			if (!force && shouldAskForApprove) {
				console.log(withStyle.warning('Found data-loss statements:'));
				console.log(infoToPrint.join('\n'));
				console.log();
				console.log(
					chalk.red.bold(
						'THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED\n',
					),
				);

				console.log(chalk.white('Do you still want to push changes?'));

Domain

Subdomains

Calls

Frequently Asked Questions

What does singlestorePush() do?
singlestorePush() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/push.ts.
Where is singlestorePush() defined?
singlestorePush() is defined in drizzle-kit/src/cli/commands/push.ts at line 166.
What does singlestorePush() call?
singlestorePush() calls 1 function(s): render.

Analyze Your Own Codebase

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

Try Supermodel Free