preparePgSchema() — drizzle-orm Function Reference
Architecture documentation for the preparePgSchema() function in studio.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 0d28bd98_0942_3298_4b65_820dc501377d["preparePgSchema()"] 82de12f8_a8ca_9d38_8da8_9ac945d81e01["studio.ts"] 0d28bd98_0942_3298_4b65_820dc501377d -->|defined in| 82de12f8_a8ca_9d38_8da8_9ac945d81e01 72630e5c_93c3_75d3_29f3_af0928ebe15c["studio.handler()"] 72630e5c_93c3_75d3_29f3_af0928ebe15c -->|calls| 0d28bd98_0942_3298_4b65_820dc501377d 54221957_c725_0bfe_4345_4f3837d39296["safeRegister()"] 0d28bd98_0942_3298_4b65_820dc501377d -->|calls| 54221957_c725_0bfe_4345_4f3837d39296 style 0d28bd98_0942_3298_4b65_820dc501377d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/serializer/studio.ts lines 90–124
export const preparePgSchema = async (path: string | string[]) => {
const imports = prepareFilenames(path);
const pgSchema: Record<string, Record<string, AnyPgTable>> = {};
const relations: Record<string, Relations> = {};
// files content as string
const files = imports.map((it, index) => ({
// get the file name from the path
name: it.split('/').pop() || `schema${index}.ts`,
content: fs.readFileSync(it, 'utf-8'),
}));
const { unregister } = await safeRegister();
for (let i = 0; i < imports.length; i++) {
const it = imports[i];
const i0: Record<string, unknown> = require(`${it}`);
const i0values = Object.entries(i0);
i0values.forEach(([k, t]) => {
if (is(t, PgTable)) {
const schema = pgTableConfig(t).schema || 'public';
pgSchema[schema] = pgSchema[schema] || {};
pgSchema[schema][k] = t;
}
if (is(t, Relations)) {
relations[k] = t;
}
});
}
unregister();
return { schema: pgSchema, relations, files };
};
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does preparePgSchema() do?
preparePgSchema() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/studio.ts.
Where is preparePgSchema() defined?
preparePgSchema() is defined in drizzle-kit/src/serializer/studio.ts at line 90.
What does preparePgSchema() call?
preparePgSchema() calls 1 function(s): safeRegister.
What calls preparePgSchema()?
preparePgSchema() is called by 1 function(s): studio.handler.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free