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

squashSqliteScheme() — drizzle-orm Function Reference

Architecture documentation for the squashSqliteScheme() function in sqliteSchema.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  dec1e114_a97f_91d6_7d9a_a12a7c1789b4["squashSqliteScheme()"]
  03c276d3_0efe_66e2_9ba9_e67edbf29418["sqliteSchema.ts"]
  dec1e114_a97f_91d6_7d9a_a12a7c1789b4 -->|defined in| 03c276d3_0efe_66e2_9ba9_e67edbf29418
  5e95b18e_139e_8c27_e72d_c0cfdaf7f698["generateSQLiteMigration()"]
  5e95b18e_139e_8c27_e72d_c0cfdaf7f698 -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  c7dae276_9495_03b3_6785_ff0423e3125c["pushSQLiteSchema()"]
  c7dae276_9495_03b3_6785_ff0423e3125c -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  48e57773_0c49_6169_cb5a_31a468e64025["introspectSqlite()"]
  48e57773_0c49_6169_cb5a_31a468e64025 -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  49e2c573_17ba_89fe_104a_c5be22a2db77["introspectLibSQL()"]
  49e2c573_17ba_89fe_104a_c5be22a2db77 -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  34d42b06_7a19_f47a_1ff9_7b6752ce0bda["prepareAndMigrateSqlite()"]
  34d42b06_7a19_f47a_1ff9_7b6752ce0bda -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  e98285fc_bf83_3aca_170c_8c0849802008["prepareAndExportSqlite()"]
  e98285fc_bf83_3aca_170c_8c0849802008 -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  fb79a54b_99a5_2063_0a0c_a9cc728865a9["prepareAndMigrateLibSQL()"]
  fb79a54b_99a5_2063_0a0c_a9cc728865a9 -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  86d84611_0fad_b786_2a9e_f7b234a52b6c["prepareAndExportLibSQL()"]
  86d84611_0fad_b786_2a9e_f7b234a52b6c -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  2ca89631_0f00_005d_5d76_39522f9fdfff["prepareSQLitePush()"]
  2ca89631_0f00_005d_5d76_39522f9fdfff -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  bc8e732d_406a_2bba_c78e_33845d67094a["prepareLibSQLPush()"]
  bc8e732d_406a_2bba_c78e_33845d67094a -->|calls| dec1e114_a97f_91d6_7d9a_a12a7c1789b4
  920ff56d_9b78_d6a4_9c81_c1e6a3d1d992["mapValues()"]
  dec1e114_a97f_91d6_7d9a_a12a7c1789b4 -->|calls| 920ff56d_9b78_d6a4_9c81_c1e6a3d1d992
  style dec1e114_a97f_91d6_7d9a_a12a7c1789b4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/sqliteSchema.ts lines 268–330

export const squashSqliteScheme = (
	json: SQLiteSchema | SQLiteSchemaV4,
	action?: 'push' | undefined,
): SQLiteSchemaSquashed => {
	const mappedTables = Object.fromEntries(
		Object.entries(json.tables).map((it) => {
			const squashedIndexes = mapValues(it[1].indexes, (index: Index) => {
				return SQLiteSquasher.squashIdx(index);
			});

			const squashedFKs = customMapEntries<string, ForeignKey>(
				it[1].foreignKeys,
				(key, value) => {
					return action === 'push'
						? [
							SQLiteSquasher.squashPushFK(value),
							SQLiteSquasher.squashPushFK(value),
						]
						: [key, SQLiteSquasher.squashFK(value)];
				},
			);

			const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
				return SQLiteSquasher.squashPK(pk);
			});

			const squashedUniqueConstraints = mapValues(
				it[1].uniqueConstraints,
				(unq) => {
					return SQLiteSquasher.squashUnique(unq);
				},
			);

			const squashedCheckConstraints = mapValues(
				it[1].checkConstraints,
				(check) => {
					return SQLiteSquasher.squashCheck(check);
				},
			);

			return [
				it[0],
				{
					name: it[1].name,
					columns: it[1].columns,
					indexes: squashedIndexes,
					foreignKeys: squashedFKs,
					compositePrimaryKeys: squashedPKs,
					uniqueConstraints: squashedUniqueConstraints,
					checkConstraints: squashedCheckConstraints,
				},
			];
		}),
	);

	return {
		version: '6',
		dialect: json.dialect,
		tables: mappedTables,
		views: json.views,
		enums: json.enums,
	};
};

Domain

Subdomains

Calls

Frequently Asked Questions

What does squashSqliteScheme() do?
squashSqliteScheme() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/sqliteSchema.ts.
Where is squashSqliteScheme() defined?
squashSqliteScheme() is defined in drizzle-kit/src/serializer/sqliteSchema.ts at line 268.
What does squashSqliteScheme() call?
squashSqliteScheme() calls 1 function(s): mapValues.
What calls squashSqliteScheme()?
squashSqliteScheme() is called by 10 function(s): generateSQLiteMigration, introspectLibSQL, introspectSqlite, prepareAndExportLibSQL, prepareAndExportSqlite, prepareAndMigrateLibSQL, prepareAndMigrateSqlite, prepareLibSQLPush, and 2 more.

Analyze Your Own Codebase

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

Try Supermodel Free