jsonDiffer.js — drizzle-orm Source File
Architecture documentation for jsonDiffer.js, a javascript file in the drizzle-orm codebase. 1 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 42cd5bcb_caa4_6b61_11ea_da1b767eeadd["jsonDiffer.js"] 2488447c_f221_12e2_8131_3229a2b07c98["json-diff"] 42cd5bcb_caa4_6b61_11ea_da1b767eeadd --> 2488447c_f221_12e2_8131_3229a2b07c98 582ba146_631b_7794_80a3_5b8044ba7cde["snapshotsDiffer.ts"] 582ba146_631b_7794_80a3_5b8044ba7cde --> 42cd5bcb_caa4_6b61_11ea_da1b767eeadd style 42cd5bcb_caa4_6b61_11ea_da1b767eeadd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
'use-strict';
import { diff } from 'json-diff';
export function diffForRenamedTables(pairs) {
// raname table1 to name of table2, so we can apply diffs
const renamed = pairs.map((it) => {
const from = it.from;
const to = it.to;
const newFrom = { ...from, name: to.name };
return [newFrom, to];
});
// find any alternations made to a renamed table
const altered = renamed.map((pair) => {
return diffForRenamedTable(pair[0], pair[1]);
});
return altered;
}
function diffForRenamedTable(t1, t2) {
t1.name = t2.name;
const diffed = diff(t1, t2) || {};
diffed.name = t2.name;
return findAlternationsInTable(diffed, t2.schema);
}
export function diffForRenamedColumn(t1, t2) {
const renamed = { ...t1, name: t2.name };
const diffed = diff(renamed, t2) || {};
diffed.name = t2.name;
return alternationsInColumn(diffed);
}
const update1to2 = (json) => {
Object.entries(json).forEach(([key, val]) => {
if ('object' !== typeof val) return;
if (val.hasOwnProperty('references')) {
const ref = val['references'];
const fkName = ref['foreignKeyName'];
const table = ref['table'];
const column = ref['column'];
const onDelete = ref['onDelete'];
const onUpdate = ref['onUpdate'];
const newRef = `${fkName};${table};${column};${onDelete ?? ''};${onUpdate ?? ''}`;
val['references'] = newRef;
} else {
update1to2(val);
}
});
};
const mapArraysDiff = (source, diff) => {
const sequence = [];
let sourceIndex = 0;
for (let i = 0; i < diff.length; i++) {
const it = diff[i];
// ... (811 more lines)
Domain
Subdomains
Functions
Dependencies
- json-diff
Imported By
Source
Frequently Asked Questions
What does jsonDiffer.js do?
jsonDiffer.js is a source file in the drizzle-orm codebase, written in javascript. It belongs to the DrizzleKit domain, CLIWorkflow subdomain.
What functions are defined in jsonDiffer.js?
jsonDiffer.js defines 12 function(s): alternationsInColumn, applyJsonDiff, diffColumns, diffForRenamedColumn, diffForRenamedTable, diffForRenamedTables, diffIndPolicies, diffPolicies, diffSchemasOrTables, findAlternationsInTable, and 2 more.
What does jsonDiffer.js depend on?
jsonDiffer.js imports 1 module(s): json-diff.
What files import jsonDiffer.js?
jsonDiffer.js is imported by 1 file(s): snapshotsDiffer.ts.
Where is jsonDiffer.js in the architecture?
jsonDiffer.js is located at drizzle-kit/src/jsonDiffer.js (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free