mysqlUp.ts — drizzle-orm Source File
Architecture documentation for mysqlUp.ts, a typescript file in the drizzle-orm codebase. 12 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 290757cc_8ec0_769b_cd24_8074fcebc663["mysqlUp.ts"] f2ee16c1_40e6_43f3_15b2_c391a3ac170b["mysqlSchema.ts"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> f2ee16c1_40e6_43f3_15b2_c391a3ac170b 2c8e6825_d659_16ea_af7a_522f31b91540["Column"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 2c8e6825_d659_16ea_af7a_522f31b91540 b8ffbc78_4812_3db2_2657_70d0793f7d8e["MySqlSchema"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> b8ffbc78_4812_3db2_2657_70d0793f7d8e 446ad0c1_6c0f_b8d0_e75b_f89379f97603["MySqlSchemaV4"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 446ad0c1_6c0f_b8d0_e75b_f89379f97603 3257a18f_30bf_5c81_20b6_2fd5d139b2b0["MySqlSchemaV5"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 3257a18f_30bf_5c81_20b6_2fd5d139b2b0 9b983cca_d8cf_f392_5545_aab8e936bcfe["Table"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 9b983cca_d8cf_f392_5545_aab8e936bcfe 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a 3f325b6b_14df_fa20_c5d7_83c98bc3d75c["prepareOutFolder"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 3f325b6b_14df_fa20_c5d7_83c98bc3d75c b18145b4_f05d_a9ae_4a8e_98368ec2cf0d["validateWithReport"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> b18145b4_f05d_a9ae_4a8e_98368ec2cf0d 0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 0f00c7dd_5eba_f1f8_c559_a99431086500 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7["fs"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7 412eac48_6e13_8b0f_b7b2_5c943c225130["path"] 290757cc_8ec0_769b_cd24_8074fcebc663 --> 412eac48_6e13_8b0f_b7b2_5c943c225130 5bf76609_579e_d312_b33b_ab5b8b683111["schema.ts"] 5bf76609_579e_d312_b33b_ab5b8b683111 --> 290757cc_8ec0_769b_cd24_8074fcebc663 style 290757cc_8ec0_769b_cd24_8074fcebc663 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import chalk from 'chalk';
import fs, { writeFileSync } from 'fs';
import path from 'path';
import { Column, MySqlSchema, MySqlSchemaV4, MySqlSchemaV5, mysqlSchemaV5, Table } from '../../serializer/mysqlSchema';
import { prepareOutFolder, validateWithReport } from '../../utils';
export const upMysqlHandler = (out: string) => {};
export const upMySqlHandlerV4toV5 = (obj: MySqlSchemaV4): MySqlSchemaV5 => {
const mappedTables: Record<string, Table> = {};
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;
let newAutoIncrement: boolean | undefined = column.autoincrement;
if (column.type.toLowerCase().startsWith('datetime')) {
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('datetime (', 'datetime(');
} else 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];
}
}
newType = column.type.toLowerCase().replace('date (', 'date(');
} 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('decimal')) {
newType = column.type.toLowerCase().replace(', ', ',');
} else if (column.type.toLowerCase().startsWith('enum')) {
newType = column.type.toLowerCase();
} else if (column.type.toLowerCase().startsWith('serial')) {
newAutoIncrement = true;
}
mappedColumns[ckey] = {
...column,
default: newDefault,
type: newType,
autoincrement: newAutoIncrement,
};
}
mappedTables[key] = {
...table,
columns: mappedColumns,
compositePrimaryKeys: {},
uniqueConstraints: {},
checkConstraint: {},
};
}
return {
version: '5',
dialect: obj.dialect,
id: obj.id,
prevId: obj.prevId,
tables: mappedTables,
schemas: obj.schemas,
_meta: {
schemas: {} as Record<string, string>,
tables: {} as Record<string, string>,
columns: {} as Record<string, string>,
},
};
};
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does mysqlUp.ts do?
mysqlUp.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, CLIWorkflow subdomain.
What functions are defined in mysqlUp.ts?
mysqlUp.ts defines 2 function(s): upMySqlHandlerV4toV5, upMysqlHandler.
What does mysqlUp.ts depend on?
mysqlUp.ts imports 12 module(s): Column, MySqlSchema, MySqlSchemaV4, MySqlSchemaV5, Table, chalk, fs, mysqlSchema.ts, and 4 more.
What files import mysqlUp.ts?
mysqlUp.ts is imported by 1 file(s): schema.ts.
Where is mysqlUp.ts in the architecture?
mysqlUp.ts is located at drizzle-kit/src/cli/commands/mysqlUp.ts (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src/cli/commands).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free