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

squashMysqlScheme() — drizzle-orm Function Reference

Architecture documentation for the squashMysqlScheme() function in mysqlSchema.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  f3976464_9993_b7cc_1cb7_d8087b203650["squashMysqlScheme()"]
  f2ee16c1_40e6_43f3_15b2_c391a3ac170b["mysqlSchema.ts"]
  f3976464_9993_b7cc_1cb7_d8087b203650 -->|defined in| f2ee16c1_40e6_43f3_15b2_c391a3ac170b
  3334c70a_3efc_ac6c_11fa_8ac2c3304af4["generateMySQLMigration()"]
  3334c70a_3efc_ac6c_11fa_8ac2c3304af4 -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  e6e192c7_531c_3883_7d01_93a5da8e7116["pushMySQLSchema()"]
  e6e192c7_531c_3883_7d01_93a5da8e7116 -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  50854fb8_da44_d90e_33cd_3524dcf8268c["introspectMysql()"]
  50854fb8_da44_d90e_33cd_3524dcf8268c -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  f33a49b1_2979_711d_4a14_81aa99a6f2a0["prepareMySQLPush()"]
  f33a49b1_2979_711d_4a14_81aa99a6f2a0 -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  41b84052_7d33_8f63_3c95_ec57735ef60e["prepareAndMigrateMysql()"]
  41b84052_7d33_8f63_3c95_ec57735ef60e -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  eaa78cbd_5a13_740d_6e64_0c3173007ebb["prepareAndExportMysql()"]
  eaa78cbd_5a13_740d_6e64_0c3173007ebb -->|calls| f3976464_9993_b7cc_1cb7_d8087b203650
  920ff56d_9b78_d6a4_9c81_c1e6a3d1d992["mapValues()"]
  f3976464_9993_b7cc_1cb7_d8087b203650 -->|calls| 920ff56d_9b78_d6a4_9c81_c1e6a3d1d992
  style f3976464_9993_b7cc_1cb7_d8087b203650 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/mysqlSchema.ts lines 338–399

export const squashMysqlScheme = (json: MySqlSchema): MySqlSchemaSquashed => {
	const mappedTables = Object.fromEntries(
		Object.entries(json.tables).map((it) => {
			const squashedIndexes = mapValues(it[1].indexes, (index) => {
				return MySqlSquasher.squashIdx(index);
			});

			const squashedFKs = mapValues(it[1].foreignKeys, (fk) => {
				return MySqlSquasher.squashFK(fk);
			});

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

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

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

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

	const mappedViews = Object.fromEntries(
		Object.entries(json.views).map(([key, value]) => {
			const meta = MySqlSquasher.squashView(value);

			return [key, {
				name: value.name,
				isExisting: value.isExisting,
				columns: value.columns,
				definition: value.definition,
				meta,
			}];
		}),
	);

	return {
		version: '5',
		dialect: json.dialect,
		tables: mappedTables,
		views: mappedViews,
	};
};

Domain

Subdomains

Calls

Frequently Asked Questions

What does squashMysqlScheme() do?
squashMysqlScheme() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/mysqlSchema.ts.
Where is squashMysqlScheme() defined?
squashMysqlScheme() is defined in drizzle-kit/src/serializer/mysqlSchema.ts at line 338.
What does squashMysqlScheme() call?
squashMysqlScheme() calls 1 function(s): mapValues.
What calls squashMysqlScheme()?
squashMysqlScheme() is called by 6 function(s): generateMySQLMigration, introspectMysql, prepareAndExportMysql, prepareAndMigrateMysql, prepareMySQLPush, pushMySQLSchema.

Analyze Your Own Codebase

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

Try Supermodel Free