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

promptNamedConflict() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  126ab305_3fa8_2818_7c79_ac4dbf1e27c1["promptNamedConflict()"]
  b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"]
  126ab305_3fa8_2818_7c79_ac4dbf1e27c1 -->|defined in| b14d3855_8cce_38c9_8952_a9d014c2fb1b
  5c0a4ada_35a6_8e1f_890c_a7fb92ef6116["roleResolver()"]
  5c0a4ada_35a6_8e1f_890c_a7fb92ef6116 -->|calls| 126ab305_3fa8_2818_7c79_ac4dbf1e27c1
  0be76621_eac6_138b_22d0_4d7d5741d5d3["indPolicyResolver()"]
  0be76621_eac6_138b_22d0_4d7d5741d5d3 -->|calls| 126ab305_3fa8_2818_7c79_ac4dbf1e27c1
  b0ef3d06_896b_eefc_c410_dfb419673d70["error()"]
  126ab305_3fa8_2818_7c79_ac4dbf1e27c1 -->|calls| b0ef3d06_896b_eefc_c410_dfb419673d70
  9ede9a38_b1b5_ce9d_c690_714bf96b1a3e["isRenamePromptItem()"]
  126ab305_3fa8_2818_7c79_ac4dbf1e27c1 -->|calls| 9ede9a38_b1b5_ce9d_c690_714bf96b1a3e
  style 126ab305_3fa8_2818_7c79_ac4dbf1e27c1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/cli/commands/migrate.ts lines 1133–1203

export const promptNamedConflict = async <T extends Named>(
	newItems: T[],
	missingItems: T[],
	entity: 'role' | 'policy',
): Promise<{
	created: T[];
	renamed: { from: T; to: T }[];
	deleted: T[];
}> => {
	if (missingItems.length === 0 || newItems.length === 0) {
		return {
			created: newItems,
			renamed: [],
			deleted: missingItems,
		};
	}

	const result: {
		created: T[];
		renamed: { from: T; to: T }[];
		deleted: T[];
	} = { created: [], renamed: [], deleted: [] };
	let index = 0;
	let leftMissing = [...missingItems];
	do {
		const created = newItems[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 ResolveSelectNamed<T>(created, promptData, entity),
		);
		if (status === 'aborted') {
			console.error('ERROR');
			process.exit(1);
		}

		if (isRenamePromptItem(data)) {
			console.log(
				`${chalk.yellow('~')} ${data.from.name} › ${data.to.name} ${
					chalk.gray(
						`${entity} will be renamed/moved`,
					)
				}`,
			);

			if (data.from.name !== data.to.name) {
				result.renamed.push(data);
			}

			delete leftMissing[leftMissing.indexOf(data.from)];
			leftMissing = leftMissing.filter(Boolean);
		} else {
			console.log(
				`${chalk.green('+')} ${data.name} ${
					chalk.gray(
						`${entity} will be created`,
					)
				}`,
			);
			result.created.push(created);
		}
		index += 1;
	} while (index < newItems.length);
	console.log(chalk.gray(`--- all ${entity} conflicts resolved ---\n`));
	result.deleted.push(...leftMissing);
	return result;
};

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free