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

singlestorePushUtils.ts — drizzle-orm Source File

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

File typescript DrizzleKit CLIWorkflow 15 imports 1 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  65107a57_7714_63e5_7018_8c2efc0f3b41["singlestorePushUtils.ts"]
  6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 6139f734_8ada_c641_9fec_9a55cfdf376f
  7a1b44f0_5378_cfe9_f22c_0b634a4efb4a["JsonAlterColumnTypeStatement"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 7a1b44f0_5378_cfe9_f22c_0b634a4efb4a
  01a65a15_492e_372b_ce91_8e23fbd7b487["JsonStatement"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 01a65a15_492e_372b_ce91_8e23fbd7b487
  d63c81a6_6779_4926_bffe_7351e12a4301["singlestoreSchema.ts"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> d63c81a6_6779_4926_bffe_7351e12a4301
  8dcd1f45_dc3b_e271_1b2d_5f24f4c459ed["Column"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 8dcd1f45_dc3b_e271_1b2d_5f24f4c459ed
  57685c31_5dce_5e65_ed14_35a5274af516["SingleStoreSchemaSquashed"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 57685c31_5dce_5e65_ed14_35a5274af516
  5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a
  2b006da9_92ff_ab47_ba6c_8ec3d041f7e3["findAddedAndRemoved"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 2b006da9_92ff_ab47_ba6c_8ec3d041f7e3
  78dc1315_e71e_ad0d_dd8e_8ff968c12ee5["selector-ui.ts"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 78dc1315_e71e_ad0d_dd8e_8ff968c12ee5
  9934e2c6_9f05_2845_f34b_12d10c0c69f6["Select"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 9934e2c6_9f05_2845_f34b_12d10c0c69f6
  502fb53b_89d2_ec40_3a24_f05850833f68["outputs.ts"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 502fb53b_89d2_ec40_3a24_f05850833f68
  0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 0f00c7dd_5eba_f1f8_c559_a99431086500
  a506b568_7d24_7568_35df_af935066e9fd["hanji"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> a506b568_7d24_7568_35df_af935066e9fd
  774a5bcf_0249_ea85_1495_1e68030f1ed3["sqlgenerator"]
  65107a57_7714_63e5_7018_8c2efc0f3b41 --> 774a5bcf_0249_ea85_1495_1e68030f1ed3
  style 65107a57_7714_63e5_7018_8c2efc0f3b41 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import chalk from 'chalk';
import { render } from 'hanji';
import { fromJson } from 'src/sqlgenerator';
import { TypeOf } from 'zod';
import { JsonAlterColumnTypeStatement, JsonStatement } from '../../jsonStatements';
import { Column, SingleStoreSchemaSquashed, SingleStoreSquasher } from '../../serializer/singlestoreSchema';
import { singlestoreSchema } from '../../serializer/singlestoreSchema';
import { type DB, findAddedAndRemoved } from '../../utils';
import { Select } from '../selector-ui';
import { withStyle } from '../validations/outputs';

export const filterStatements = (
	statements: JsonStatement[],
	currentSchema: TypeOf<typeof singlestoreSchema>,
	prevSchema: TypeOf<typeof singlestoreSchema>,
) => {
	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 = SingleStoreSquasher.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"
// ... (397 more lines)

Domain

Subdomains

Frequently Asked Questions

What does singlestorePushUtils.ts do?
singlestorePushUtils.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 singlestorePushUtils.ts?
singlestorePushUtils.ts defines 3 function(s): filterStatements, findColumnTypeAlternations, logSuggestionsAndReturn.
What does singlestorePushUtils.ts depend on?
singlestorePushUtils.ts imports 15 module(s): Column, JsonAlterColumnTypeStatement, JsonStatement, Select, SingleStoreSchemaSquashed, chalk, findAddedAndRemoved, hanji, and 7 more.
What files import singlestorePushUtils.ts?
singlestorePushUtils.ts is imported by 1 file(s): push.ts.
Where is singlestorePushUtils.ts in the architecture?
singlestorePushUtils.ts is located at drizzle-kit/src/cli/commands/singlestorePushUtils.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