提交 2bcd3587 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 更新日期时间字段以支持字符串模式

上级 348a4f52
...@@ -15,7 +15,6 @@ export const getMysqlPool = () => { ...@@ -15,7 +15,6 @@ export const getMysqlPool = () => {
pool = mysql.createPool({ pool = mysql.createPool({
...connectionOptions, ...connectionOptions,
timezone: '+08:00',
waitForConnections: true, waitForConnections: true,
connectionLimit: 10, connectionLimit: 10,
queueLimit: 0, queueLimit: 0,
......
...@@ -2,8 +2,8 @@ import { datetime } from 'drizzle-orm/mysql-core' ...@@ -2,8 +2,8 @@ import { datetime } from 'drizzle-orm/mysql-core'
import { sql } from 'drizzle-orm' import { sql } from 'drizzle-orm'
export const timestamps = { export const timestamps = {
createdAt: datetime('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), createdAt: datetime('created_at', { mode: 'string' }).notNull().default(sql`CURRENT_TIMESTAMP`),
updatedAt: datetime('updated_at') updatedAt: datetime('updated_at', { mode: 'string' })
.notNull() .notNull()
.default(sql`CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`), .default(sql`CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`),
} }
...@@ -19,15 +19,6 @@ const optionalId = z.preprocess( ...@@ -19,15 +19,6 @@ const optionalId = z.preprocess(
const fileListValue = z.string().nullish() const fileListValue = z.string().nullish()
const caseFile = z.object({
type: z.string().min(1).max(16),
type_name: z.string().max(120).optional(),
name: z.string().min(1).max(255),
url: z.string().min(1).max(1000),
created_at: z.string().optional(),
updated_at: z.string().optional(),
})
// ── products ───────────────────────────────────────────────────────── // ── products ─────────────────────────────────────────────────────────
export const productsListQuery = z.object({ export const productsListQuery = z.object({
...@@ -66,7 +57,7 @@ const caseBody = z.object({ ...@@ -66,7 +57,7 @@ const caseBody = z.object({
description: z.string().trim().optional(), description: z.string().trim().optional(),
productId: optionalId, productId: optionalId,
productName: z.string().max(255).optional(), productName: z.string().max(255).optional(),
files: z.array(caseFile).optional(), files: z.array(z.unknown()).optional(),
}) })
export const caseCreateBody = caseBody export const caseCreateBody = caseBody
......
...@@ -25,7 +25,7 @@ export const projectRoleAssignments = mysqlTable('project_role_assignments', { ...@@ -25,7 +25,7 @@ export const projectRoleAssignments = mysqlTable('project_role_assignments', {
role: varchar('role', { length: 32 }).notNull(), role: varchar('role', { length: 32 }).notNull(),
status: tinyint('status', { unsigned: true }).notNull().default(1), status: tinyint('status', { unsigned: true }).notNull().default(1),
assignedBySsoId: varchar('assigned_by_sso_id', { length: 64 }), assignedBySsoId: varchar('assigned_by_sso_id', { length: 64 }),
assignedAt: datetime('assigned_at').notNull().default(sql`CURRENT_TIMESTAMP`), assignedAt: datetime('assigned_at', { mode: 'string' }).notNull().default(sql`CURRENT_TIMESTAMP`),
...timestamps, ...timestamps,
}, (table) => ({ }, (table) => ({
projectIdx: index('idx_project_roles_project_id').on(table.projectId), projectIdx: index('idx_project_roles_project_id').on(table.projectId),
......
...@@ -128,7 +128,7 @@ export const deliveries = mysqlTable('project_deliveries', { ...@@ -128,7 +128,7 @@ export const deliveries = mysqlTable('project_deliveries', {
deliveryContact: varchar('delivery_contact', { length: 120 }), deliveryContact: varchar('delivery_contact', { length: 120 }),
deliveryContactPhone: varchar('delivery_contact_phone', { length: 64 }), deliveryContactPhone: varchar('delivery_contact_phone', { length: 64 }),
deliveryNote: text('delivery_note'), deliveryNote: text('delivery_note'),
completedAt: datetime('completed_at'), completedAt: datetime('completed_at', { mode: 'string' }),
...timestamps, ...timestamps,
}, (table) => ({ }, (table) => ({
projectIdIdx: uniqueIndex('uk_deliveries_project_id').on(table.projectId), projectIdIdx: uniqueIndex('uk_deliveries_project_id').on(table.projectId),
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论