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

diffTestSchemasPushSqlite() — drizzle-orm Function Reference

Architecture documentation for the diffTestSchemasPushSqlite() function in schemaDiffer.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145["diffTestSchemasPushSqlite()"]
  fb6b4a65_030b_ce6b_df0d_2be21adcd2b3["schemaDiffer.ts"]
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 -->|defined in| fb6b4a65_030b_ce6b_df0d_2be21adcd2b3
  0edb9fbe_a5ec_9995_347a_9ea655353950["applySqliteDiffs()"]
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 -->|calls| 0edb9fbe_a5ec_9995_347a_9ea655353950
  fd1b2256_62ed_ec7e_c677_9d8cbf56136b["testTablesResolver()"]
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 -->|calls| fd1b2256_62ed_ec7e_c677_9d8cbf56136b
  96edd91d_9f30_fc37_cbd3_7c1229315b14["testColumnsResolver()"]
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 -->|calls| 96edd91d_9f30_fc37_cbd3_7c1229315b14
  ca971472_1126_152f_0fc8_502996a52ea8["testViewsResolverSqlite()"]
  cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 -->|calls| ca971472_1126_152f_0fc8_502996a52ea8
  style cb68215e_fbbc_c2e1_0cbe_6e65ee0bd145 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/tests/schemaDiffer.ts lines 1818–1938

export const diffTestSchemasPushSqlite = async (
	client: Database,
	left: SqliteSchema,
	right: SqliteSchema,
	renamesArr: string[],
	cli: boolean = false,
	seedStatements: string[] = [],
	casing?: CasingType | undefined,
) => {
	const { sqlStatements } = await applySqliteDiffs(left, 'push');

	for (const st of sqlStatements) {
		client.exec(st);
	}

	for (const st of seedStatements) {
		client.exec(st);
	}

	// do introspect into PgSchemaInternal
	const introspectedSchema = await fromSqliteDatabase(
		{
			query: async <T>(sql: string, params: any[] = []) => {
				return client.prepare(sql).bind(params).all() as T[];
			},
			run: async (query: string) => {
				client.prepare(query).run();
			},
		},
		undefined,
	);

	const rightTables = Object.values(right).filter((it) => is(it, SQLiteTable)) as SQLiteTable[];

	const rightViews = Object.values(right).filter((it) => is(it, SQLiteView)) as SQLiteView[];

	const serialized2 = generateSqliteSnapshot(rightTables, rightViews, casing);

	const { version: v1, dialect: d1, ...rest1 } = introspectedSchema;
	const { version: v2, dialect: d2, ...rest2 } = serialized2;

	const sch1 = {
		version: '6',
		dialect: 'sqlite',
		id: '0',
		prevId: '0',
		...rest1,
	} as const;

	const sch2 = {
		version: '6',
		dialect: 'sqlite',
		id: '0',
		prevId: '0',
		...rest2,
	} as const;

	const sn1 = squashSqliteScheme(sch1, 'push');
	const sn2 = squashSqliteScheme(sch2, 'push');

	const renames = new Set(renamesArr);

	if (!cli) {
		const { sqlStatements, statements, _meta } = await applySqliteSnapshotsDiff(
			sn1,
			sn2,
			testTablesResolver(renames),
			testColumnsResolver(renames),
			testViewsResolverSqlite(renames),
			sch1,
			sch2,
			'push',
		);

		const {
			statementsToExecute,
			columnsToRemove,
			infoToPrint,
			schemasToRemove,
			shouldAskForApprove,
			tablesToRemove,

Domain

Subdomains

Frequently Asked Questions

What does diffTestSchemasPushSqlite() do?
diffTestSchemasPushSqlite() is a function in the drizzle-orm codebase, defined in drizzle-kit/tests/schemaDiffer.ts.
Where is diffTestSchemasPushSqlite() defined?
diffTestSchemasPushSqlite() is defined in drizzle-kit/tests/schemaDiffer.ts at line 1818.
What does diffTestSchemasPushSqlite() call?
diffTestSchemasPushSqlite() calls 4 function(s): applySqliteDiffs, testColumnsResolver, testTablesResolver, testViewsResolverSqlite.

Analyze Your Own Codebase

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

Try Supermodel Free