refactor: 重构数据模型,移除用户表并新增待办事项表

- 将导出内容从用户模型改为待办事项模型。
- 创建待办事项数据表,包含唯一标识、标题、完成状态、创建与更新时间字段,并设置默认值和自动更新机制。
- 删除用户表数据模型定义
This commit is contained in:
2026-01-17 02:23:28 +08:00
parent 95176adf6d
commit d0c203df74
3 changed files with 16 additions and 8 deletions

View File

@@ -1 +1 @@
export * from './user'
export * from './todo'

15
src/db/schema/todo.ts Normal file
View File

@@ -0,0 +1,15 @@
import { sql } from 'drizzle-orm'
import { boolean, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core'
export const todoTable = pgTable('todo', {
id: uuid('id').primaryKey().default(sql`uuidv7()`),
title: text('title').notNull(),
completed: boolean('completed').notNull().default(false),
createdAt: timestamp('created_at', { withTimezone: true })
.notNull()
.defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true })
.notNull()
.defaultNow()
.$onUpdateFn(() => new Date()),
})

View File

@@ -1,7 +0,0 @@
import { sql } from 'drizzle-orm'
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
export const userTable = pgTable('user', {
id: uuid('id').primaryKey().default(sql`uuidv7()`),
name: text('name').notNull(),
})