forked from imbytecat/fullstack-starter
refactor: 重构数据模型,移除用户表并新增待办事项表
- 将导出内容从用户模型改为待办事项模型。 - 创建待办事项数据表,包含唯一标识、标题、完成状态、创建与更新时间字段,并设置默认值和自动更新机制。 - 删除用户表数据模型定义
This commit is contained in:
@@ -1 +1 @@
|
||||
export * from './user'
|
||||
export * from './todo'
|
||||
|
||||
15
src/db/schema/todo.ts
Normal file
15
src/db/schema/todo.ts
Normal 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()),
|
||||
})
|
||||
@@ -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(),
|
||||
})
|
||||
Reference in New Issue
Block a user