logSuggestionsAndReturn() — drizzle-orm Function Reference
Architecture documentation for the logSuggestionsAndReturn() function in mysqlPushUtils.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD d906c913_0bfa_0d4d_e180_62a6d24c7d6e["logSuggestionsAndReturn()"] b387f7cb_f080_cc3a_a94d_1e2775ef2400["mysqlPushUtils.ts"] d906c913_0bfa_0d4d_e180_62a6d24c7d6e -->|defined in| b387f7cb_f080_cc3a_a94d_1e2775ef2400 a6191ddf_c119_718d_8adb_1cf1f8e385b3["render()"] d906c913_0bfa_0d4d_e180_62a6d24c7d6e -->|calls| a6191ddf_c119_718d_8adb_1cf1f8e385b3 style d906c913_0bfa_0d4d_e180_62a6d24c7d6e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/commands/mysqlPushUtils.ts lines 107–352
export const logSuggestionsAndReturn = async (
db: DB,
statements: JsonStatement[],
json2: TypeOf<typeof mysqlSchema>,
) => {
let shouldAskForApprove = false;
const statementsToExecute: string[] = [];
const infoToPrint: string[] = [];
const tablesToRemove: string[] = [];
const columnsToRemove: string[] = [];
const schemasToRemove: string[] = [];
const tablesToTruncate: string[] = [];
for (const statement of statements) {
if (statement.type === 'drop_table') {
const res = await db.query(
`select count(*) as count from \`${statement.tableName}\``,
);
const count = Number(res[0].count);
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
statement.tableName,
)
} table with ${count} items`,
);
tablesToRemove.push(statement.tableName);
shouldAskForApprove = true;
}
} else if (statement.type === 'alter_table_drop_column') {
const res = await db.query(
`select count(*) as count from \`${statement.tableName}\``,
);
const count = Number(res[0].count);
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
statement.columnName,
)
} column in ${statement.tableName} table with ${count} items`,
);
columnsToRemove.push(`${statement.tableName}_${statement.columnName}`);
shouldAskForApprove = true;
}
} else if (statement.type === 'drop_schema') {
const res = await db.query(
`select count(*) as count from information_schema.tables where table_schema = \`${statement.name}\`;`,
);
const count = Number(res[0].count);
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
statement.name,
)
} schema with ${count} tables`,
);
schemasToRemove.push(statement.name);
shouldAskForApprove = true;
}
} else if (statement.type === 'alter_table_alter_column_set_type') {
const res = await db.query(
`select count(*) as count from \`${statement.tableName}\``,
);
const count = Number(res[0].count);
if (count > 0) {
infoToPrint.push(
`· You're about to change ${
chalk.underline(
statement.columnName,
)
} column type from ${
chalk.underline(
statement.oldDataType,
)
} to ${chalk.underline(statement.newDataType)} with ${count} items`,
);
statementsToExecute.push(`truncate table ${statement.tableName};`);
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does logSuggestionsAndReturn() do?
logSuggestionsAndReturn() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/mysqlPushUtils.ts.
Where is logSuggestionsAndReturn() defined?
logSuggestionsAndReturn() is defined in drizzle-kit/src/cli/commands/mysqlPushUtils.ts at line 107.
What does logSuggestionsAndReturn() call?
logSuggestionsAndReturn() calls 1 function(s): render.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free