forked from imbytecat/fullstack-starter
refactor: 重构数据库相关代码并更新依赖
- 添加本地数据库包依赖以支持项目数据库功能 - 导出 todoTable 以供数据库 schema 使用 - 移除对 todo 模式的导出 - 删除待办事项数据表的定义配置 - 重命名文件以更准确地反映其用途,将数据库相关工具函数集中到新的工具文件中。 - 将数据库创建函数的导入路径从 '@/db' 更新为 '@/db/utils'。 - 将数据库包版本更新为1.0.0并添加对工作区中数据库包的依赖。
This commit is contained in:
1
apps/server/src/db/schema.ts
Normal file
1
apps/server/src/db/schema.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { todoTable } from '@furtherverse/database/postgres/schema/index'
|
||||
@@ -1 +0,0 @@
|
||||
export * from './todo'
|
||||
@@ -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()),
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { os } from '@orpc/server'
|
||||
import { createDb } from '@/db'
|
||||
import { createDb } from '@/db/utils'
|
||||
|
||||
const IS_SERVERLESS = false // TODO: 这里需要优化
|
||||
|
||||
|
||||
Reference in New Issue
Block a user