mysqlSchemaSuggestions() — drizzle-orm Function Reference
Architecture documentation for the mysqlSchemaSuggestions() function in migrate.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 1b4504df_dcdc_a9cd_7341_5dbc85579a6e["mysqlSchemaSuggestions()"] b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"] 1b4504df_dcdc_a9cd_7341_5dbc85579a6e -->|defined in| b14d3855_8cce_38c9_8952_a9d014c2fb1b style 1b4504df_dcdc_a9cd_7341_5dbc85579a6e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/commands/migrate.ts lines 440–488
function mysqlSchemaSuggestions(
curSchema: TypeOf<typeof mysqlSchema>,
prevSchema: TypeOf<typeof mysqlSchema>,
) {
const suggestions: string[] = [];
const usedSuggestions: string[] = [];
const suggestionTypes = {
serial: withStyle.errorWarning(
`We deprecated the use of 'serial' for MySQL starting from version 0.20.0. In MySQL, 'serial' is simply an alias for 'bigint unsigned not null auto_increment unique,' which creates all constraints and indexes for you. This may make the process less explicit for both users and drizzle-kit push commands`,
),
};
for (const table of Object.values(curSchema.tables)) {
for (const column of Object.values(table.columns)) {
if (column.type === 'serial') {
if (!usedSuggestions.includes('serial')) {
suggestions.push(suggestionTypes['serial']);
}
const uniqueForSerial = Object.values(
prevSchema.tables[table.name].uniqueConstraints,
).find((it) => it.columns[0] === column.name);
suggestions.push(
`\n`
+ withStyle.suggestion(
`We are suggesting to change ${
chalk.blue(
column.name,
)
} column in ${
chalk.blueBright(
table.name,
)
} table from serial to bigint unsigned\n\n${
chalk.blueBright(
`bigint("${column.name}", { mode: "number", unsigned: true }).notNull().autoincrement().unique(${
uniqueForSerial?.name ? `"${uniqueForSerial?.name}"` : ''
})`,
)
}`,
),
);
}
}
}
return suggestions;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does mysqlSchemaSuggestions() do?
mysqlSchemaSuggestions() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/migrate.ts.
Where is mysqlSchemaSuggestions() defined?
mysqlSchemaSuggestions() is defined in drizzle-kit/src/cli/commands/migrate.ts at line 440.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free