schema() — drizzle-orm Function Reference
Architecture documentation for the schema() function in views.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD dd999a0b_2e45_a358_d4ac_692136f9cd09["schema()"] 217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"] dd999a0b_2e45_a358_d4ac_692136f9cd09 -->|defined in| 217e2cbd_4fb7_ceab_251c_5733ece08a8f cb2d3951_4fcb_d824_359b_9f044d2f7e6c["writeResult()"] cb2d3951_4fcb_d824_359b_9f044d2f7e6c -->|calls| dd999a0b_2e45_a358_d4ac_692136f9cd09 fefc5532_e3ca_1d01_fbbf_3aa1af2ee3b0["objectValues()"] dd999a0b_2e45_a358_d4ac_692136f9cd09 -->|calls| fefc5532_e3ca_1d01_fbbf_3aa1af2ee3b0 style dd999a0b_2e45_a358_d4ac_692136f9cd09 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/views.ts lines 25–76
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) {
msg += '\n';
msg += chalk.bold(`${enums.length} enums\n`);
msg += enums
.map((it) => {
return `${chalk.bold.blue(it.name)} ${
chalk.gray(
`[${Object.values(it.values).join(', ')}]`,
)
}`;
})
.join('\n');
msg += '\n';
}
return msg;
};
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does schema() do?
schema() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/views.ts.
Where is schema() defined?
schema() is defined in drizzle-kit/src/cli/views.ts at line 25.
What does schema() call?
schema() calls 1 function(s): objectValues.
What calls schema()?
schema() is called by 1 function(s): writeResult.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free