Home / Class/ DropMigrationView Class — drizzle-orm Architecture

DropMigrationView Class — drizzle-orm Architecture

Architecture documentation for the DropMigrationView class in views.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  129d37bd_998c_ca67_437a_70f89493fa5d["DropMigrationView"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"]
  129d37bd_998c_ca67_437a_70f89493fa5d -->|defined in| 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  ff29355f_b92f_2063_5613_72c709d2ce29["constructor()"]
  129d37bd_998c_ca67_437a_70f89493fa5d -->|method| ff29355f_b92f_2063_5613_72c709d2ce29
  5300a679_d9ea_0981_226a_556588f8f2d0["render()"]
  129d37bd_998c_ca67_437a_70f89493fa5d -->|method| 5300a679_d9ea_0981_226a_556588f8f2d0
  b55a447c_964f_b29e_9f9f_aacd420a45b1["result()"]
  129d37bd_998c_ca67_437a_70f89493fa5d -->|method| b55a447c_964f_b29e_9f9f_aacd420a45b1

Relationship Graph

Source Code

drizzle-kit/src/cli/views.ts lines 578–625

export class DropMigrationView<T extends { tag: string }> extends Prompt<T> {
	private readonly data: SelectState<T>;

	constructor(data: T[]) {
		super();
		this.on('attach', (terminal) => terminal.toggleCursor('hide'));
		this.data = new SelectState(data);
		this.data.selectedIdx = data.length - 1;
		this.data.bind(this);
	}

	render(status: 'idle' | 'submitted' | 'aborted'): string {
		if (status === 'submitted' || status === 'aborted') {
			return '\n';
		}

		let text = chalk.bold('Please select migration to drop:\n');
		const selectedPrefix = chalk.yellow('❯ ');

		const data = trimmedRange(this.data.items, this.data.selectedIdx, 9);
		const labelLength: number = data.trimmed
			.map((it) => it.tag.length)
			.reduce((a, b) => {
				if (a > b) {
					return a;
				}
				return b;
			}, 0);

		text += data.startTrimmed ? '  ...\n' : '';

		data.trimmed.forEach((it, idx) => {
			const isSelected = idx === this.data.selectedIdx - data.offset;
			let title = it.tag.padEnd(labelLength, ' ');
			title = isSelected ? chalk.yellow(title) : title;

			text += isSelected ? `${selectedPrefix}${title}` : `  ${title}`;
			text += idx != this.data.items.length - 1 ? '\n' : '';
		});

		text += data.endTrimmed ? '  ...\n' : '';
		return text;
	}

	result(): T {
		return this.data.items[this.data.selectedIdx]!;
	}
}

Domain

Frequently Asked Questions

What is the DropMigrationView class?
DropMigrationView is a class in the drizzle-orm codebase, defined in drizzle-kit/src/cli/views.ts.
Where is DropMigrationView defined?
DropMigrationView is defined in drizzle-kit/src/cli/views.ts at line 578.

Analyze Your Own Codebase

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

Try Supermodel Free