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

pgPushUtils.ts — drizzle-orm Source File

Architecture documentation for pgPushUtils.ts, a typescript file in the drizzle-orm codebase. 9 imports, 2 dependents.

File typescript DrizzleKit CLIWorkflow 9 imports 2 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  1f0f6821_4b66_fcbb_186f_e1b78872b924["pgPushUtils.ts"]
  6139f734_8ada_c641_9fec_9a55cfdf376f["jsonStatements.ts"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> 6139f734_8ada_c641_9fec_9a55cfdf376f
  cbf63853_6723_30fc_5ded_88a8944f77c4["pgSchema.ts"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> cbf63853_6723_30fc_5ded_88a8944f77c4
  fe4174c7_3b9c_5b26_98a0_b2395ca21939["sqlgenerator.ts"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> fe4174c7_3b9c_5b26_98a0_b2395ca21939
  f532f7a9_3781_5a3c_9695_e62bd56cabd7["fromJson"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> f532f7a9_3781_5a3c_9695_e62bd56cabd7
  5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a
  78dc1315_e71e_ad0d_dd8e_8ff968c12ee5["selector-ui.ts"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> 78dc1315_e71e_ad0d_dd8e_8ff968c12ee5
  9934e2c6_9f05_2845_f34b_12d10c0c69f6["Select"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> 9934e2c6_9f05_2845_f34b_12d10c0c69f6
  0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> 0f00c7dd_5eba_f1f8_c559_a99431086500
  a506b568_7d24_7568_35df_af935066e9fd["hanji"]
  1f0f6821_4b66_fcbb_186f_e1b78872b924 --> a506b568_7d24_7568_35df_af935066e9fd
  e668bfef_9125_1ef0_2f94_a0f9605584bd["api.ts"]
  e668bfef_9125_1ef0_2f94_a0f9605584bd --> 1f0f6821_4b66_fcbb_186f_e1b78872b924
  6219550e_1686_ca7a_0d96_0838fb90e7cb["push.ts"]
  6219550e_1686_ca7a_0d96_0838fb90e7cb --> 1f0f6821_4b66_fcbb_186f_e1b78872b924
  style 1f0f6821_4b66_fcbb_186f_e1b78872b924 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import chalk from 'chalk';
import { render } from 'hanji';
import type { JsonStatement } from '../../jsonStatements';
import { PgSquasher } from '../../serializer/pgSchema';
import { fromJson } from '../../sqlgenerator';
import type { DB } from '../../utils';
import { Select } from '../selector-ui';

// export const filterStatements = (statements: JsonStatement[]) => {
//   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;
//       }
//     } 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;
//       }
//     }
//     return true;
//   });
// };

function concatSchemaAndTableName(schema: string | undefined, table: string) {
	return schema ? `"${schema}"."${table}"` : `"${table}"`;
}

function tableNameWithSchemaFrom(
	schema: string | undefined,
	tableName: string,
	renamedSchemas: Record<string, string>,
	renamedTables: Record<string, string>,
) {
	const newSchemaName = schema ? (renamedSchemas[schema] ? renamedSchemas[schema] : schema) : undefined;

	const newTableName = renamedTables[concatSchemaAndTableName(newSchemaName, tableName)]
		? renamedTables[concatSchemaAndTableName(newSchemaName, tableName)]
		: tableName;

	return concatSchemaAndTableName(newSchemaName, newTableName);
}

export const pgSuggestions = async (db: DB, statements: JsonStatement[]) => {
	let shouldAskForApprove = false;
// ... (210 more lines)

Domain

Subdomains

Frequently Asked Questions

What does pgPushUtils.ts do?
pgPushUtils.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 pgPushUtils.ts?
pgPushUtils.ts defines 3 function(s): concatSchemaAndTableName, pgSuggestions, tableNameWithSchemaFrom.
What does pgPushUtils.ts depend on?
pgPushUtils.ts imports 9 module(s): Select, chalk, fromJson, hanji, jsonStatements.ts, pgSchema.ts, selector-ui.ts, sqlgenerator.ts, and 1 more.
What files import pgPushUtils.ts?
pgPushUtils.ts is imported by 2 file(s): api.ts, push.ts.
Where is pgPushUtils.ts in the architecture?
pgPushUtils.ts is located at drizzle-kit/src/cli/commands/pgPushUtils.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