prepareLibSQLCreateReferencesJson() — drizzle-orm Function Reference
Architecture documentation for the prepareLibSQLCreateReferencesJson() function in jsonStatements.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 7c3cc283_c1ad_ca11_ec79_32d1bcc62f7a["prepareLibSQLCreateReferencesJson()"] 6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"] 7c3cc283_c1ad_ca11_ec79_32d1bcc62f7a -->|defined in| 6139f734_8ada_c641_9fec_9a55cfdf376f 55569cde_7638_9cfc_9dcd_34636d975ec3["applyLibSQLSnapshotsDiff()"] 55569cde_7638_9cfc_9dcd_34636d975ec3 -->|calls| 7c3cc283_c1ad_ca11_ec79_32d1bcc62f7a style 7c3cc283_c1ad_ca11_ec79_32d1bcc62f7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/jsonStatements.ts lines 2939–2986
export const prepareLibSQLCreateReferencesJson = (
tableName: string,
schema: string,
foreignKeys: Record<string, string>,
json2: SQLiteSchemaSquashed,
action?: 'push',
): JsonCreateReferenceStatement[] => {
return Object.values(foreignKeys).map((fkData) => {
const { columnsFrom, tableFrom, columnsTo } = action === 'push'
? SQLiteSquasher.unsquashPushFK(fkData)
: SQLiteSquasher.unsquashFK(fkData);
// When trying to alter table in lib sql it is necessary to pass all config for column like "NOT NULL", "DEFAULT", etc.
// If it is multicolumn reference it is not possible to pass this data for all columns
// Pass multicolumn flag for sql statements to not generate migration
let isMulticolumn = false;
if (columnsFrom.length > 1 || columnsTo.length > 1) {
isMulticolumn = true;
return {
type: 'create_reference',
tableName,
data: fkData,
schema,
isMulticolumn,
};
}
const columnFrom = columnsFrom[0];
const {
notNull: columnNotNull,
default: columnDefault,
type: columnType,
} = json2.tables[tableFrom].columns[columnFrom];
return {
type: 'create_reference',
tableName,
data: fkData,
schema,
columnNotNull,
columnDefault,
columnType,
};
});
};
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does prepareLibSQLCreateReferencesJson() do?
prepareLibSQLCreateReferencesJson() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/jsonStatements.ts.
Where is prepareLibSQLCreateReferencesJson() defined?
prepareLibSQLCreateReferencesJson() is defined in drizzle-kit/src/jsonStatements.ts at line 2939.
What calls prepareLibSQLCreateReferencesJson()?
prepareLibSQLCreateReferencesJson() is called by 1 function(s): applyLibSQLSnapshotsDiff.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free