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

Function diffTestSchemasPushSqlite

drizzle-kit/tests/schemaDiffer.ts:1818–1938  ·  view source on GitHub ↗
(
	client: Database,
	left: SqliteSchema,
	right: SqliteSchema,
	renamesArr: string[],
	cli: boolean = false,
	seedStatements: string[] = [],
	casing?: CasingType | undefined,
)

Source from the content-addressed store, hash-verified

1816};
1817
1818export const diffTestSchemasPushSqlite = async (
1819 client: Database,
1820 left: SqliteSchema,
1821 right: SqliteSchema,
1822 renamesArr: string[],
1823 cli: boolean = false,
1824 seedStatements: string[] = [],
1825 casing?: CasingType | undefined,
1826) => {
1827 const { sqlStatements } = await applySqliteDiffs(left, 'push');
1828
1829 for (const st of sqlStatements) {
1830 client.exec(st);
1831 }
1832
1833 for (const st of seedStatements) {
1834 client.exec(st);
1835 }
1836
1837 // do introspect into PgSchemaInternal
1838 const introspectedSchema = await fromSqliteDatabase(
1839 {
1840 query: async <T>(sql: string, params: any[] = []) => {
1841 return client.prepare(sql).bind(params).all() as T[];
1842 },
1843 run: async (query: string) => {
1844 client.prepare(query).run();
1845 },
1846 },
1847 undefined,
1848 );
1849
1850 const rightTables = Object.values(right).filter((it) => is(it, SQLiteTable)) as SQLiteTable[];
1851
1852 const rightViews = Object.values(right).filter((it) => is(it, SQLiteView)) as SQLiteView[];
1853
1854 const serialized2 = generateSqliteSnapshot(rightTables, rightViews, casing);
1855
1856 const { version: v1, dialect: d1, ...rest1 } = introspectedSchema;
1857 const { version: v2, dialect: d2, ...rest2 } = serialized2;
1858
1859 const sch1 = {
1860 version: '6',
1861 dialect: 'sqlite',
1862 id: '0',
1863 prevId: '0',
1864 ...rest1,
1865 } as const;
1866
1867 const sch2 = {
1868 version: '6',
1869 dialect: 'sqlite',
1870 id: '0',
1871 prevId: '0',
1872 ...rest2,
1873 } as const;
1874
1875 const sn1 = squashSqliteScheme(sch1, 'push');

Callers 1

sqlite.test.tsFile · 0.90

Calls 14

isFunction · 0.90
generateSqliteSnapshotFunction · 0.90
squashSqliteSchemeFunction · 0.90
applySqliteSnapshotsDiffFunction · 0.90
logSuggestionsAndReturnFunction · 0.90
applySqliteDiffsFunction · 0.85
testTablesResolverFunction · 0.85
testColumnsResolverFunction · 0.85
testViewsResolverSqliteFunction · 0.85
execMethod · 0.80
allMethod · 0.45
prepareMethod · 0.45

Tested by

no test coverage detected