Home / File/ mysqlPushUtils.ts — drizzle-orm Source File

mysqlPushUtils.ts — drizzle-orm Source File

Architecture documentation for mysqlPushUtils.ts, a typescript file in the drizzle-orm codebase. 11 imports, 1 dependents.

File typescript DrizzleKit CLIWorkflow 11 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  b387f7cb_f080_cc3a_a94d_1e2775ef2400["mysqlPushUtils.ts"]
  6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 6139f734_8ada_c641_9fec_9a55cfdf376f
  7a1b44f0_5378_cfe9_f22c_0b634a4efb4a["JsonAlterColumnTypeStatement"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 7a1b44f0_5378_cfe9_f22c_0b634a4efb4a
  01a65a15_492e_372b_ce91_8e23fbd7b487["JsonStatement"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 01a65a15_492e_372b_ce91_8e23fbd7b487
  f2ee16c1_40e6_43f3_15b2_c391a3ac170b["mysqlSchema.ts"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> f2ee16c1_40e6_43f3_15b2_c391a3ac170b
  5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a
  78dc1315_e71e_ad0d_dd8e_8ff968c12ee5["selector-ui.ts"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 78dc1315_e71e_ad0d_dd8e_8ff968c12ee5
  9934e2c6_9f05_2845_f34b_12d10c0c69f6["Select"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 9934e2c6_9f05_2845_f34b_12d10c0c69f6
  502fb53b_89d2_ec40_3a24_f05850833f68["outputs.ts"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 502fb53b_89d2_ec40_3a24_f05850833f68
  0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 0f00c7dd_5eba_f1f8_c559_a99431086500
  a506b568_7d24_7568_35df_af935066e9fd["hanji"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> a506b568_7d24_7568_35df_af935066e9fd
  9d8cc145_835b_8147_2ea5_b7b5383ae775["zod"]
  b387f7cb_f080_cc3a_a94d_1e2775ef2400 --> 9d8cc145_835b_8147_2ea5_b7b5383ae775
  6219550e_1686_ca7a_0d96_0838fb90e7cb["push.ts"]
  6219550e_1686_ca7a_0d96_0838fb90e7cb --> b387f7cb_f080_cc3a_a94d_1e2775ef2400
  style b387f7cb_f080_cc3a_a94d_1e2775ef2400 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import chalk from 'chalk';
import { render } from 'hanji';
import { TypeOf } from 'zod';
import { JsonAlterColumnTypeStatement, JsonStatement } from '../../jsonStatements';
import { mysqlSchema, MySqlSquasher } from '../../serializer/mysqlSchema';
import type { DB } from '../../utils';
import { Select } from '../selector-ui';
import { withStyle } from '../validations/outputs';

export const filterStatements = (
	statements: JsonStatement[],
	currentSchema: TypeOf<typeof mysqlSchema>,
	prevSchema: TypeOf<typeof mysqlSchema>,
) => {
	return statements.filter((statement) => {
		if (statement.type === 'alter_table_alter_column_set_type') {
			// Don't need to handle it on migrations step and introspection
			// but for both it should be skipped
			if (
				statement.oldDataType.startsWith('tinyint')
				&& statement.newDataType.startsWith('boolean')
			) {
				return false;
			}

			if (
				statement.oldDataType.startsWith('bigint unsigned')
				&& statement.newDataType.startsWith('serial')
			) {
				return false;
			}

			if (
				statement.oldDataType.startsWith('serial')
				&& statement.newDataType.startsWith('bigint unsigned')
			) {
				return false;
			}
		} else if (statement.type === 'alter_table_alter_column_set_default') {
			if (
				statement.newDefaultValue === false
				&& statement.oldDefaultValue === 0
				&& statement.newDataType === 'boolean'
			) {
				return false;
			}
			if (
				statement.newDefaultValue === true
				&& statement.oldDefaultValue === 1
				&& statement.newDataType === 'boolean'
			) {
				return false;
			}
		} else if (statement.type === 'delete_unique_constraint') {
			const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
			// only if constraint was removed from a serial column, than treat it as removed
			// const serialStatement = statements.find(
			//   (it) => it.type === "alter_table_alter_column_set_type"
			// ) as JsonAlterColumnTypeStatement;
			// if (
// ... (293 more lines)

Domain

Subdomains

Frequently Asked Questions

What does mysqlPushUtils.ts do?
mysqlPushUtils.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, CLIWorkflow subdomain.
What functions are defined in mysqlPushUtils.ts?
mysqlPushUtils.ts defines 2 function(s): filterStatements, logSuggestionsAndReturn.
What does mysqlPushUtils.ts depend on?
mysqlPushUtils.ts imports 11 module(s): JsonAlterColumnTypeStatement, JsonStatement, Select, chalk, hanji, jsonStatements.ts, mysqlSchema.ts, outputs.ts, and 3 more.
What files import mysqlPushUtils.ts?
mysqlPushUtils.ts is imported by 1 file(s): push.ts.
Where is mysqlPushUtils.ts in the architecture?
mysqlPushUtils.ts is located at drizzle-kit/src/cli/commands/mysqlPushUtils.ts (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src/cli/commands).

Analyze Your Own Codebase

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

Try Supermodel Free