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

Function applySingleStoreDiffs

drizzle-kit/tests/schemaDiffer.ts:1765–1816  ·  view source on GitHub ↗
(
	sn: SinglestoreSchema,
	casing: CasingType | undefined,
)

Source from the content-addressed store, hash-verified

1763};
1764
1765export const applySingleStoreDiffs = async (
1766 sn: SinglestoreSchema,
1767 casing: CasingType | undefined,
1768) => {
1769 const dryRun = {
1770 version: '1',
1771 dialect: 'singlestore',
1772 id: '0',
1773 prevId: '0',
1774 tables: {},
1775 views: {},
1776 enums: {},
1777 schemas: {},
1778 _meta: {
1779 schemas: {},
1780 tables: {},
1781 columns: {},
1782 },
1783 } as const;
1784
1785 const tables = Object.values(sn).filter((it) => is(it, SingleStoreTable)) as SingleStoreTable[];
1786
1787 /* const views = Object.values(sn).filter((it) => is(it, SingleStoreView)) as SingleStoreView[]; */
1788
1789 const serialized1 = generateSingleStoreSnapshot(tables, /* views, */ casing);
1790
1791 const { version: v1, dialect: d1, ...rest1 } = serialized1;
1792
1793 const sch1 = {
1794 version: '1',
1795 dialect: 'singlestore',
1796 id: '0',
1797 prevId: '0',
1798 ...rest1,
1799 } as const;
1800
1801 const sn1 = squashSingleStoreScheme(sch1);
1802
1803 const validatedPrev = singlestoreSchema.parse(dryRun);
1804 const validatedCur = singlestoreSchema.parse(sch1);
1805
1806 const { sqlStatements, statements } = await applySingleStoreSnapshotsDiff(
1807 dryRun,
1808 sn1,
1809 testTablesResolver(new Set()),
1810 testColumnsResolver(new Set()),
1811 /* testViewsResolverSingleStore(new Set()), */
1812 validatedPrev,
1813 validatedCur,
1814 );
1815 return { sqlStatements, statements };
1816};
1817
1818export const diffTestSchemasPushSqlite = async (
1819 client: Database,

Callers 2

Calls 7

isFunction · 0.90
squashSingleStoreSchemeFunction · 0.90
testTablesResolverFunction · 0.85
testColumnsResolverFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected