Home / Function/ alternationsInColumn() — drizzle-orm Function Reference

alternationsInColumn() — drizzle-orm Function Reference

Architecture documentation for the alternationsInColumn() function in jsonDiffer.js from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  8b823a7b_e100_8757_c26e_074b85993748["alternationsInColumn()"]
  42cd5bcb_caa4_6b61_11ea_da1b767eeadd["jsonDiffer.js"]
  8b823a7b_e100_8757_c26e_074b85993748 -->|defined in| 42cd5bcb_caa4_6b61_11ea_da1b767eeadd
  fa522ef5_7b17_086d_cc32_d827ab692d9a["diffForRenamedColumn()"]
  fa522ef5_7b17_086d_cc32_d827ab692d9a -->|calls| 8b823a7b_e100_8757_c26e_074b85993748
  906f6136_df62_f258_6513_16b2c830beec["findAlternationsInTable()"]
  906f6136_df62_f258_6513_16b2c830beec -->|calls| 8b823a7b_e100_8757_c26e_074b85993748
  style 8b823a7b_e100_8757_c26e_074b85993748 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/jsonDiffer.js lines 574–870

const alternationsInColumn = (column) => {
	const altered = [column];

	const result = altered
		.filter((it) => {
			if ('type' in it && it.type.__old.replace(' (', '(') === it.type.__new.replace(' (', '(')) {
				return false;
			}
			return true;
		})
		.map((it) => {
			if (typeof it.name !== 'string' && '__old' in it.name) {
				// rename
				return {
					...it,
					name: { type: 'changed', old: it.name.__old, new: it.name.__new },
				};
			}
			return it;
		})
		.map((it) => {
			if ('type' in it) {
				// type change
				return {
					...it,
					type: { type: 'changed', old: it.type.__old, new: it.type.__new },
				};
			}
			return it;
		})
		.map((it) => {
			if ('default' in it) {
				return {
					...it,
					default: {
						type: 'changed',
						old: it.default.__old,
						new: it.default.__new,
					},
				};
			}
			if ('default__added' in it) {
				const { default__added, ...others } = it;
				return {
					...others,
					default: { type: 'added', value: it.default__added },
				};
			}
			if ('default__deleted' in it) {
				const { default__deleted, ...others } = it;
				return {
					...others,
					default: { type: 'deleted', value: it.default__deleted },
				};
			}
			return it;
		})
		.map((it) => {
			if ('generated' in it) {
				if ('as' in it.generated && 'type' in it.generated) {
					return {
						...it,
						generated: {
							type: 'changed',
							old: { as: it.generated.as.__old, type: it.generated.type.__old },
							new: { as: it.generated.as.__new, type: it.generated.type.__new },
						},
					};
				} else if ('as' in it.generated) {
					return {
						...it,
						generated: {
							type: 'changed',
							old: { as: it.generated.as.__old },
							new: { as: it.generated.as.__new },
						},
					};
				} else {
					return {
						...it,
						generated: {

Domain

Subdomains

Frequently Asked Questions

What does alternationsInColumn() do?
alternationsInColumn() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/jsonDiffer.js.
Where is alternationsInColumn() defined?
alternationsInColumn() is defined in drizzle-kit/src/jsonDiffer.js at line 574.
What calls alternationsInColumn()?
alternationsInColumn() is called by 2 function(s): diffForRenamedColumn, findAlternationsInTable.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free