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

promptSchemasConflict() — drizzle-orm Function Reference

Architecture documentation for the promptSchemasConflict() function in migrate.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  d89e1ac3_6d18_f095_84cc_b14d18b26f37["promptSchemasConflict()"]
  b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"]
  d89e1ac3_6d18_f095_84cc_b14d18b26f37 -->|defined in| b14d3855_8cce_38c9_8952_a9d014c2fb1b
  ea26ea35_7e38_edd5_dcf4_9309d7a255a4["schemasResolver()"]
  ea26ea35_7e38_edd5_dcf4_9309d7a255a4 -->|calls| d89e1ac3_6d18_f095_84cc_b14d18b26f37
  b0ef3d06_896b_eefc_c410_dfb419673d70["error()"]
  d89e1ac3_6d18_f095_84cc_b14d18b26f37 -->|calls| b0ef3d06_896b_eefc_c410_dfb419673d70
  9ede9a38_b1b5_ce9d_c690_714bf96b1a3e["isRenamePromptItem()"]
  d89e1ac3_6d18_f095_84cc_b14d18b26f37 -->|calls| 9ede9a38_b1b5_ce9d_c690_714bf96b1a3e
  style d89e1ac3_6d18_f095_84cc_b14d18b26f37 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/cli/commands/migrate.ts lines 1295–1352

export const promptSchemasConflict = async <T extends Named>(
	newSchemas: T[],
	missingSchemas: T[],
): Promise<{ created: T[]; renamed: { from: T; to: T }[]; deleted: T[] }> => {
	if (missingSchemas.length === 0 || newSchemas.length === 0) {
		return { created: newSchemas, renamed: [], deleted: missingSchemas };
	}

	const result: { created: T[]; renamed: { from: T; to: T }[]; deleted: T[] } = {
		created: [],
		renamed: [],
		deleted: [],
	};
	let index = 0;
	let leftMissing = [...missingSchemas];
	do {
		const created = newSchemas[index];
		const renames: RenamePropmtItem<T>[] = leftMissing.map((it) => {
			return { from: it, to: created };
		});

		const promptData: (RenamePropmtItem<T> | T)[] = [created, ...renames];

		const { status, data } = await render(
			new ResolveSchemasSelect<T>(created, promptData),
		);
		if (status === 'aborted') {
			console.error('ERROR');
			process.exit(1);
		}

		if (isRenamePromptItem(data)) {
			console.log(
				`${chalk.yellow('~')} ${data.from.name} › ${data.to.name} ${
					chalk.gray(
						'schema will be renamed',
					)
				}`,
			);
			result.renamed.push(data);
			delete leftMissing[leftMissing.indexOf(data.from)];
			leftMissing = leftMissing.filter(Boolean);
		} else {
			console.log(
				`${chalk.green('+')} ${data.name} ${
					chalk.gray(
						'schema will be created',
					)
				}`,
			);
			result.created.push(created);
		}
		index += 1;
	} while (index < newSchemas.length);
	console.log(chalk.gray('--- all schemas conflicts resolved ---\n'));
	result.deleted.push(...leftMissing);
	return result;
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does promptSchemasConflict() do?
promptSchemasConflict() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/migrate.ts.
Where is promptSchemasConflict() defined?
promptSchemasConflict() is defined in drizzle-kit/src/cli/commands/migrate.ts at line 1295.
What does promptSchemasConflict() call?
promptSchemasConflict() calls 2 function(s): error, isRenamePromptItem.
What calls promptSchemasConflict()?
promptSchemasConflict() is called by 1 function(s): schemasResolver.

Analyze Your Own Codebase

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

Try Supermodel Free