convert() — drizzle-orm Function Reference
Architecture documentation for the convert() function in sqlgenerator.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 2d618809_9374_2760_a1b8_aeeeb02ac67c["convert()"] 30c88950_d016_3a7f_aac0_60ee746478c7["AlterTypeDropValueConvertor"] 2d618809_9374_2760_a1b8_aeeeb02ac67c -->|defined in| 30c88950_d016_3a7f_aac0_60ee746478c7 b0591d99_981e_0c05_5ac1_486f87aa1678["parseType()"] 2d618809_9374_2760_a1b8_aeeeb02ac67c -->|calls| b0591d99_981e_0c05_5ac1_486f87aa1678 style 2d618809_9374_2760_a1b8_aeeeb02ac67c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/sqlgenerator.ts lines 1467–1514
convert(st: JsonDropValueFromEnumStatement) {
const { columnsWithEnum, name, newValues, enumSchema } = st;
const statements: string[] = [];
for (const withEnum of columnsWithEnum) {
const tableNameWithSchema = withEnum.tableSchema
? `"${withEnum.tableSchema}"."${withEnum.table}"`
: `"${withEnum.table}"`;
statements.push(
`ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${withEnum.column}" SET DATA TYPE text;`,
);
if (withEnum.default) {
statements.push(
`ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${withEnum.column}" SET DEFAULT ${withEnum.default}::text;`,
);
}
}
statements.push(new DropTypeEnumConvertor().convert({ name: name, schema: enumSchema, type: 'drop_type_enum' }));
statements.push(new CreateTypeEnumConvertor().convert({
name: name,
schema: enumSchema,
values: newValues,
type: 'create_type_enum',
}));
for (const withEnum of columnsWithEnum) {
const tableNameWithSchema = withEnum.tableSchema
? `"${withEnum.tableSchema}"."${withEnum.table}"`
: `"${withEnum.table}"`;
const parsedType = parseType(`"${enumSchema}".`, withEnum.columnType);
if (withEnum.default) {
statements.push(
`ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${withEnum.column}" SET DEFAULT ${withEnum.default}::${parsedType};`,
);
}
statements.push(
`ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${withEnum.column}" SET DATA TYPE ${parsedType} USING "${withEnum.column}"::${parsedType};`,
);
}
return statements;
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does convert() do?
convert() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/sqlgenerator.ts.
Where is convert() defined?
convert() is defined in drizzle-kit/src/sqlgenerator.ts at line 1467.
What does convert() call?
convert() calls 1 function(s): parseType.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free