upPgHandlerV4toV5() — drizzle-orm Function Reference
Architecture documentation for the upPgHandlerV4toV5() function in pgUp.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD e79c2792_0642_35b9_fc7e_3a85e1350914["upPgHandlerV4toV5()"] 466af62c_27ae_41b6_d841_1dc8334565a4["pgUp.ts"] e79c2792_0642_35b9_fc7e_3a85e1350914 -->|defined in| 466af62c_27ae_41b6_d841_1dc8334565a4 style e79c2792_0642_35b9_fc7e_3a85e1350914 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/cli/commands/pgUp.ts lines 113–179
export const upPgHandlerV4toV5 = (obj: PgSchemaV4): PgSchemaV5 => {
const mappedTables: Record<string, TableV5> = {};
for (const [key, table] of Object.entries(obj.tables)) {
const mappedColumns: Record<string, Column> = {};
for (const [ckey, column] of Object.entries(table.columns)) {
let newDefault: any = column.default;
let newType: string = column.type;
if (column.type.toLowerCase() === 'date') {
if (typeof column.default !== 'undefined') {
if (column.default.startsWith("'") && column.default.endsWith("'")) {
newDefault = `'${
column.default
.substring(1, column.default.length - 1)
.split('T')[0]
}'`;
} else {
newDefault = column.default.split('T')[0];
}
}
} else if (column.type.toLowerCase().startsWith('timestamp')) {
if (typeof column.default !== 'undefined') {
if (column.default.startsWith("'") && column.default.endsWith("'")) {
newDefault = `'${
column.default
.substring(1, column.default.length - 1)
.replace('T', ' ')
.slice(0, 23)
}'`;
} else {
newDefault = column.default.replace('T', ' ').slice(0, 23);
}
}
newType = column.type
.toLowerCase()
.replace('timestamp (', 'timestamp(');
} else if (column.type.toLowerCase().startsWith('time')) {
newType = column.type.toLowerCase().replace('time (', 'time(');
} else if (column.type.toLowerCase().startsWith('interval')) {
newType = column.type.toLowerCase().replace(' (', '(');
}
mappedColumns[ckey] = { ...column, default: newDefault, type: newType };
}
mappedTables[key] = {
...table,
columns: mappedColumns,
compositePrimaryKeys: {},
uniqueConstraints: {},
};
}
return {
version: '5',
dialect: obj.dialect,
id: obj.id,
prevId: obj.prevId,
tables: mappedTables,
enums: obj.enums,
schemas: obj.schemas,
_meta: {
schemas: {} as Record<string, string>,
tables: {} as Record<string, string>,
columns: {} as Record<string, string>,
},
};
};
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does upPgHandlerV4toV5() do?
upPgHandlerV4toV5() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/cli/commands/pgUp.ts.
Where is upPgHandlerV4toV5() defined?
upPgHandlerV4toV5() is defined in drizzle-kit/src/cli/commands/pgUp.ts at line 113.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free