refactor: 重构数据库相关代码并更新依赖

- 添加本地数据库包依赖以支持项目数据库功能
- 导出 todoTable 以供数据库 schema 使用
- 移除对 todo 模式的导出
- 删除待办事项数据表的定义配置
- 重命名文件以更准确地反映其用途,将数据库相关工具函数集中到新的工具文件中。
- 将数据库创建函数的导入路径从 '@/db' 更新为 '@/db/utils'。
- 将数据库包版本更新为1.0.0并添加对工作区中数据库包的依赖。
This commit is contained in:
2026-01-21 15:47:24 +08:00
parent 28d0c9ad3d
commit 484ecd85a3
7 changed files with 5 additions and 18 deletions

View File

@@ -15,6 +15,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@furtherverse/database": "workspace:*",
"@orpc/client": "catalog:",
"@orpc/contract": "catalog:",
"@orpc/server": "catalog:",

View File

@@ -0,0 +1 @@
export { todoTable } from '@furtherverse/database/postgres/schema/index'

View File

@@ -1 +0,0 @@
export * from './todo'

View File

@@ -1,15 +0,0 @@
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,5 +1,5 @@
import { os } from '@orpc/server'
import { createDb } from '@/db'
import { createDb } from '@/db/utils'
const IS_SERVERLESS = false // TODO: 这里需要优化

View File

@@ -21,6 +21,7 @@
"name": "@furtherverse/server",
"version": "1.0.0",
"dependencies": {
"@furtherverse/database": "workspace:*",
"@orpc/client": "catalog:",
"@orpc/contract": "catalog:",
"@orpc/server": "catalog:",
@@ -64,7 +65,7 @@
},
"packages/database": {
"name": "@furtherverse/database",
"version": "0.0.0",
"version": "1.0.0",
"dependencies": {
"drizzle-orm": "catalog:",
"uuid": "catalog:",