MCPcopy
hub / github.com/drizzle-team/drizzle-orm / alternationsInColumn

Function alternationsInColumn

drizzle-kit/src/jsonDiffer.js:574–870  ·  view source on GitHub ↗
(column)

Source from the content-addressed store, hash-verified

572};
573
574const alternationsInColumn = (column) => {
575 const altered = [column];
576
577 const result = altered
578 .filter((it) => {
579 if ('type' in it && it.type.__old.replace(' (', '(') === it.type.__new.replace(' (', '(')) {
580 return false;
581 }
582 return true;
583 })
584 .map((it) => {
585 if (typeof it.name !== 'string' && '__old' in it.name) {
586 // rename
587 return {
588 ...it,
589 name: { type: 'changed', old: it.name.__old, new: it.name.__new },
590 };
591 }
592 return it;
593 })
594 .map((it) => {
595 if ('type' in it) {
596 // type change
597 return {
598 ...it,
599 type: { type: 'changed', old: it.type.__old, new: it.type.__new },
600 };
601 }
602 return it;
603 })
604 .map((it) => {
605 if ('default' in it) {
606 return {
607 ...it,
608 default: {
609 type: 'changed',
610 old: it.default.__old,
611 new: it.default.__new,
612 },
613 };
614 }
615 if ('default__added' in it) {
616 const { default__added, ...others } = it;
617 return {
618 ...others,
619 default: { type: 'added', value: it.default__added },
620 };
621 }
622 if ('default__deleted' in it) {
623 const { default__deleted, ...others } = it;
624 return {
625 ...others,
626 default: { type: 'deleted', value: it.default__deleted },
627 };
628 }
629 return it;
630 })
631 .map((it) => {

Callers 2

diffForRenamedColumnFunction · 0.85
findAlternationsInTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected