filterStatements() — drizzle-orm Function Reference
Architecture documentation for the filterStatements() function in mysqlPushUtils.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 5c1d25fb_ce50_e380_1070_f223ed9b8f49["filterStatements()"] b387f7cb_f080_cc3a_a94d_1e2775ef2400["mysqlPushUtils.ts"] 5c1d25fb_ce50_e380_1070_f223ed9b8f49 -->|defined in| b387f7cb_f080_cc3a_a94d_1e2775ef2400 5f1dc8e1_c9ac_354c_77c5_286782036654["pgPush()"] 5f1dc8e1_c9ac_354c_77c5_286782036654 -->|calls| 5c1d25fb_ce50_e380_1070_f223ed9b8f49 style 5c1d25fb_ce50_e380_1070_f223ed9b8f49 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/commands/mysqlPushUtils.ts lines 10–105
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 (
// serialStatement?.oldDataType.startsWith("bigint unsigned") &&
// serialStatement?.newDataType.startsWith("serial") &&
// serialStatement.columnName ===
// MySqlSquasher.unsquashUnique(statement.data).columns[0]
// ) {
// return false;
// }
// Check if uniqueindex was only on this column, that is serial
// if now serial and was not serial and was unique index
if (
unsquashed.columns.length === 1
&& currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]]
.type === 'serial'
&& prevSchema.tables[statement.tableName].columns[unsquashed.columns[0]]
.type === 'serial'
&& currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]]
.name === unsquashed.columns[0]
) {
return false;
}
} else if (statement.type === 'alter_table_alter_column_drop_notnull') {
// 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 (
serialStatement?.oldDataType.startsWith('bigint unsigned')
&& serialStatement?.newDataType.startsWith('serial')
&& serialStatement.columnName === statement.columnName
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does filterStatements() do?
filterStatements() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/mysqlPushUtils.ts.
Where is filterStatements() defined?
filterStatements() is defined in drizzle-kit/src/cli/commands/mysqlPushUtils.ts at line 10.
What calls filterStatements()?
filterStatements() is called by 1 function(s): pgPush.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free