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

Function diffTestSchemasPushLibSQL

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

Source from the content-addressed store, hash-verified

1938};
1939
1940export async function diffTestSchemasPushLibSQL(
1941 client: Client,
1942 left: SqliteSchema,
1943 right: SqliteSchema,
1944 renamesArr: string[],
1945 cli: boolean = false,
1946 seedStatements: string[] = [],
1947 casing?: CasingType | undefined,
1948) {
1949 const { sqlStatements } = await applyLibSQLDiffs(left, 'push');
1950
1951 for (const st of sqlStatements) {
1952 await client.execute(st);
1953 }
1954
1955 for (const st of seedStatements) {
1956 await client.execute(st);
1957 }
1958
1959 const introspectedSchema = await fromSqliteDatabase(
1960 {
1961 query: async <T>(sql: string, params?: any[]) => {
1962 const res = await client.execute({ sql, args: params || [] });
1963 return res.rows as T[];
1964 },
1965 run: async (query: string) => {
1966 await client.execute(query);
1967 },
1968 },
1969 undefined,
1970 );
1971
1972 const leftTables = Object.values(right).filter((it) => is(it, SQLiteTable)) as SQLiteTable[];
1973
1974 const leftViews = Object.values(right).filter((it) => is(it, SQLiteView)) as SQLiteView[];
1975
1976 const serialized2 = generateSqliteSnapshot(leftTables, leftViews, casing);
1977
1978 const { version: v1, dialect: d1, ...rest1 } = introspectedSchema;
1979 const { version: v2, dialect: d2, ...rest2 } = serialized2;
1980
1981 const sch1 = {
1982 version: '6',
1983 dialect: 'sqlite',
1984 id: '0',
1985 prevId: '0',
1986 ...rest1,
1987 } as const;
1988
1989 const sch2 = {
1990 version: '6',
1991 dialect: 'sqlite',
1992 id: '0',
1993 prevId: '0',
1994 ...rest2,
1995 } as const;
1996
1997 const sn1 = squashSqliteScheme(sch1, 'push');

Callers 1

libsql.test.tsFile · 0.90

Calls 11

isFunction · 0.90
generateSqliteSnapshotFunction · 0.90
squashSqliteSchemeFunction · 0.90
applyLibSQLSnapshotsDiffFunction · 0.90
applyLibSQLDiffsFunction · 0.85
testTablesResolverFunction · 0.85
testColumnsResolverFunction · 0.85
testViewsResolverSqliteFunction · 0.85
executeMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected