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

introspectSingleStore() — drizzle-orm Function Reference

Architecture documentation for the introspectSingleStore() function in introspect.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  7d387948_d073_7138_a827_23cf000dc9bc["introspectSingleStore()"]
  c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"]
  7d387948_d073_7138_a827_23cf000dc9bc -->|defined in| c2c22050_0d5c_404e_2b18_5934c728a89c
  db0c397a_220a_c404_bea0_7813784bf108["update()"]
  7d387948_d073_7138_a827_23cf000dc9bc -->|calls| db0c397a_220a_c404_bea0_7813784bf108
  3f325b6b_14df_fa20_c5d7_83c98bc3d75c["prepareOutFolder()"]
  7d387948_d073_7138_a827_23cf000dc9bc -->|calls| 3f325b6b_14df_fa20_c5d7_83c98bc3d75c
  d4992b27_bf78_8099_5134_750cef1c518c["applySingleStoreSnapshotsDiff()"]
  7d387948_d073_7138_a827_23cf000dc9bc -->|calls| d4992b27_bf78_8099_5134_750cef1c518c
  cb2d3951_4fcb_d824_359b_9f044d2f7e6c["writeResult()"]
  7d387948_d073_7138_a827_23cf000dc9bc -->|calls| cb2d3951_4fcb_d824_359b_9f044d2f7e6c
  style 7d387948_d073_7138_a827_23cf000dc9bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/cli/commands/introspect.ts lines 418–513

export const introspectSingleStore = async (
	casing: Casing,
	out: string,
	breakpoints: boolean,
	credentials: SingleStoreCredentials,
	tablesFilter: string[],
	prefix: Prefix,
) => {
	const { connectToSingleStore } = await import('../connections');
	const { db, database } = await connectToSingleStore(credentials);

	const matchers = tablesFilter.map((it) => {
		return new Minimatch(it);
	});

	const filter = (tableName: string) => {
		if (matchers.length === 0) return true;

		let flags: boolean[] = [];

		for (let matcher of matchers) {
			if (matcher.negate) {
				if (!matcher.match(tableName)) {
					flags.push(false);
				}
			}

			if (matcher.match(tableName)) {
				flags.push(true);
			}
		}

		if (flags.length > 0) {
			return flags.every(Boolean);
		}
		return false;
	};

	const progress = new IntrospectProgress();
	const res = await renderWithTask(
		progress,
		fromSingleStoreDatabase(db, database, filter, (stage, count, status) => {
			progress.update(stage, count, status);
		}),
	);

	const schema = { id: originUUID, prevId: '', ...res } as SingleStoreSchema;
	const ts = singlestoreSchemaToTypeScript(schema, casing);
	const { internal, ...schemaWithoutInternals } = schema;

	const schemaFile = join(out, 'schema.ts');
	writeFileSync(schemaFile, ts.file);
	console.log();

	const { snapshots, journal } = prepareOutFolder(out, 'postgresql');

	if (snapshots.length === 0) {
		const { sqlStatements, _meta } = await applySingleStoreSnapshotsDiff(
			squashSingleStoreScheme(drySingleStore),
			squashSingleStoreScheme(schema),
			tablesResolver,
			columnsResolver,
			/* singleStoreViewsResolver, */
			drySingleStore,
			schema,
		);

		writeResult({
			cur: schema,
			sqlStatements,
			journal,
			_meta,
			outFolder: out,
			breakpoints,
			type: 'introspect',
			prefixMode: prefix,
		});
	} else {
		render(
			`[${
				chalk.blue(

Domain

Subdomains

Frequently Asked Questions

What does introspectSingleStore() do?
introspectSingleStore() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/introspect.ts.
Where is introspectSingleStore() defined?
introspectSingleStore() is defined in drizzle-kit/src/cli/commands/introspect.ts at line 418.
What does introspectSingleStore() call?
introspectSingleStore() calls 4 function(s): applySingleStoreSnapshotsDiff, prepareOutFolder, update, writeResult.

Analyze Your Own Codebase

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

Try Supermodel Free