Home / File/ views.ts — drizzle-orm Source File

views.ts — drizzle-orm Source File

Architecture documentation for views.ts, a typescript file in the drizzle-orm codebase. 6 imports, 23 dependents.

File typescript DrizzleKit SchemaDiffer 6 imports 23 dependents 10 functions 9 classes

Entity Profile

Dependency Diagram

graph LR
  217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"]
  5e835bc2_6860_21e3_492c_babcc3e93529["schemaValidator.ts"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> 5e835bc2_6860_21e3_492c_babcc3e93529
  5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a
  fefc5532_e3ca_1d01_fbbf_3aa1af2ee3b0["objectValues"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> fefc5532_e3ca_1d01_fbbf_3aa1af2ee3b0
  b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> b14d3855_8cce_38c9_8952_a9d014c2fb1b
  0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> 0f00c7dd_5eba_f1f8_c559_a99431086500
  a506b568_7d24_7568_35df_af935066e9fd["hanji"]
  217e2cbd_4fb7_ceab_251c_5733ece08a8f --> a506b568_7d24_7568_35df_af935066e9fd
  abecef96_5a79_62f4_9fa7_4cac90f0bb61["drop.ts"]
  abecef96_5a79_62f4_9fa7_4cac90f0bb61 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"]
  c2c22050_0d5c_404e_2b18_5934c728a89c --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"]
  b14d3855_8cce_38c9_8952_a9d014c2fb1b --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  f816063a_7e7e_84b8_d556_2fad92ba1294["mysqlIntrospect.ts"]
  f816063a_7e7e_84b8_d556_2fad92ba1294 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c["pgIntrospect.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  5ace557c_1d0c_8b30_588f_2973fb2830b3["singlestoreIntrospect.ts"]
  5ace557c_1d0c_8b30_588f_2973fb2830b3 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  cea479b5_7704_0339_de4e_3cc844834ec0["sqliteIntrospect.ts"]
  cea479b5_7704_0339_de4e_3cc844834ec0 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  09e5bcf1_0f03_3dbd_fbdb_762440f28855["utils.ts"]
  09e5bcf1_0f03_3dbd_fbdb_762440f28855 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  5bf76609_579e_d312_b33b_ab5b8b683111["schema.ts"]
  5bf76609_579e_d312_b33b_ab5b8b683111 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  style 217e2cbd_4fb7_ceab_251c_5733ece08a8f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import chalk from 'chalk';
import { Prompt, render, SelectState, TaskView } from 'hanji';
import type { CommonSchema } from '../schemaValidator';
import { objectValues } from '../utils';
import type { Named, NamedWithSchema } from './commands/migrate';

export const warning = (msg: string) => {
	render(`[${chalk.yellow('Warning')}] ${msg}`);
};
export const err = (msg: string) => {
	render(`${chalk.bold.red('Error')} ${msg}`);
};

export const info = (msg: string, greyMsg: string = ''): string => {
	return `${chalk.blue.bold('Info:')} ${msg} ${greyMsg ? chalk.grey(greyMsg) : ''}`.trim();
};
export const grey = (msg: string): string => {
	return chalk.grey(msg);
};

export const error = (error: string, greyMsg: string = ''): string => {
	return `${chalk.bgRed.bold(' Error ')} ${error} ${greyMsg ? chalk.grey(greyMsg) : ''}`.trim();
};

export const schema = (schema: CommonSchema): string => {
	type TableEntry = (typeof schema)['tables'][keyof (typeof schema)['tables']];
	const tables = Object.values(schema.tables) as unknown as TableEntry[];

	let msg = chalk.bold(`${tables.length} tables\n`);

	msg += tables
		.map((t) => {
			const columnsCount = Object.values(t.columns).length;
			const indexesCount = Object.values(t.indexes).length;
			let foreignKeys: number = 0;
			// Singlestore doesn't have foreign keys
			if (schema.dialect !== 'singlestore') {
				// @ts-expect-error
				foreignKeys = Object.values(t.foreignKeys).length;
			}

			return `${chalk.bold.blue(t.name)} ${
				chalk.gray(
					`${columnsCount} columns ${indexesCount} indexes ${foreignKeys} fks`,
				)
			}`;
		})
		.join('\n');

	msg += '\n';

	const enums = objectValues(
		'enums' in schema
			? 'values' in schema['enums']
				? schema['enums']
				: {}
			: {},
	);

	if (enums.length > 0) {
// ... (599 more lines)

Domain

Subdomains

Frequently Asked Questions

What does views.ts do?
views.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, SchemaDiffer subdomain.
What functions are defined in views.ts?
views.ts defines 10 function(s): err, error, frames, grey, info, isRenamePromptItem, schema, tableKey, trimmedRange, warning.
What does views.ts depend on?
views.ts imports 6 module(s): chalk, hanji, migrate.ts, objectValues, schemaValidator.ts, utils.ts.
What files import views.ts?
views.ts is imported by 23 file(s): drop.ts, gel.ts, index.ts, introspect.ts, jsonStatements.ts, libsql.ts, migrate.ts, mysql.ts, and 15 more.
Where is views.ts in the architecture?
views.ts is located at drizzle-kit/src/cli/views.ts (domain: DrizzleKit, subdomain: SchemaDiffer, directory: drizzle-kit/src/cli).

Analyze Your Own Codebase

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

Try Supermodel Free