introspectMysql() — drizzle-orm Function Reference
Architecture documentation for the introspectMysql() function in introspect.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 50854fb8_da44_d90e_33cd_3524dcf8268c["introspectMysql()"] c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|defined in| c2c22050_0d5c_404e_2b18_5934c728a89c db0c397a_220a_c404_bea0_7813784bf108["update()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| db0c397a_220a_c404_bea0_7813784bf108 d34d3e87_b168_fea6_ac14_fef2ffdc1654["relationsToTypeScript()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| d34d3e87_b168_fea6_ac14_fef2ffdc1654 3f325b6b_14df_fa20_c5d7_83c98bc3d75c["prepareOutFolder()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| 3f325b6b_14df_fa20_c5d7_83c98bc3d75c a5972ffc_ff1b_9523_2495_5373af710e65["applyMysqlSnapshotsDiff()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| a5972ffc_ff1b_9523_2495_5373af710e65 f3976464_9993_b7cc_1cb7_d8087b203650["squashMysqlScheme()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650 cb2d3951_4fcb_d824_359b_9f044d2f7e6c["writeResult()"] 50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| cb2d3951_4fcb_d824_359b_9f044d2f7e6c style 50854fb8_da44_d90e_33cd_3524dcf8268c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/commands/introspect.ts lines 307–416
export const introspectMysql = async (
casing: Casing,
out: string,
breakpoints: boolean,
credentials: MysqlCredentials,
tablesFilter: string[],
prefix: Prefix,
) => {
const { connectToMySQL } = await import('../connections');
const { db, database } = await connectToMySQL(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,
fromMysqlDatabase(db, database, filter, (stage, count, status) => {
progress.update(stage, count, status);
}),
);
const schema = { id: originUUID, prevId: '', ...res } as MySqlSchema;
const ts = mysqlSchemaToTypeScript(schema, casing);
const relationsTs = relationsToTypeScript(schema, casing);
const { internal, ...schemaWithoutInternals } = schema;
const schemaFile = join(out, 'schema.ts');
writeFileSync(schemaFile, ts.file);
const relationsFile = join(out, 'relations.ts');
writeFileSync(relationsFile, relationsTs.file);
console.log();
const { snapshots, journal } = prepareOutFolder(out, 'mysql');
if (snapshots.length === 0) {
const { sqlStatements, _meta } = await applyMysqlSnapshotsDiff(
squashMysqlScheme(dryMySql),
squashMysqlScheme(schema),
tablesResolver,
columnsResolver,
mySqlViewsResolver,
dryMySql,
schema,
);
writeResult({
cur: schema,
sqlStatements,
journal,
_meta,
outFolder: out,
breakpoints,
type: 'introspect',
prefixMode: prefix,
});
} else {
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does introspectMysql() do?
introspectMysql() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/introspect.ts.
Where is introspectMysql() defined?
introspectMysql() is defined in drizzle-kit/src/cli/commands/introspect.ts at line 307.
What does introspectMysql() call?
introspectMysql() calls 6 function(s): applyMysqlSnapshotsDiff, prepareOutFolder, relationsToTypeScript, squashMysqlScheme, update, writeResult.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free