forked from imbytecat/fullstack-starter
refactor: 重构数据库相关代码并更新依赖
- 添加本地数据库包依赖以支持项目数据库功能 - 导出 todoTable 以供数据库 schema 使用 - 移除对 todo 模式的导出 - 删除待办事项数据表的定义配置 - 重命名文件以更准确地反映其用途,将数据库相关工具函数集中到新的工具文件中。 - 将数据库创建函数的导入路径从 '@/db' 更新为 '@/db/utils'。 - 将数据库包版本更新为1.0.0并添加对工作区中数据库包的依赖。
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@furtherverse/database": "workspace:*",
|
||||||
"@orpc/client": "catalog:",
|
"@orpc/client": "catalog:",
|
||||||
"@orpc/contract": "catalog:",
|
"@orpc/contract": "catalog:",
|
||||||
"@orpc/server": "catalog:",
|
"@orpc/server": "catalog:",
|
||||||
|
|||||||
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 { os } from '@orpc/server'
|
||||||
import { createDb } from '@/db'
|
import { createDb } from '@/db/utils'
|
||||||
|
|
||||||
const IS_SERVERLESS = false // TODO: 这里需要优化
|
const IS_SERVERLESS = false // TODO: 这里需要优化
|
||||||
|
|
||||||
|
|||||||
3
bun.lock
3
bun.lock
@@ -21,6 +21,7 @@
|
|||||||
"name": "@furtherverse/server",
|
"name": "@furtherverse/server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@furtherverse/database": "workspace:*",
|
||||||
"@orpc/client": "catalog:",
|
"@orpc/client": "catalog:",
|
||||||
"@orpc/contract": "catalog:",
|
"@orpc/contract": "catalog:",
|
||||||
"@orpc/server": "catalog:",
|
"@orpc/server": "catalog:",
|
||||||
@@ -64,7 +65,7 @@
|
|||||||
},
|
},
|
||||||
"packages/database": {
|
"packages/database": {
|
||||||
"name": "@furtherverse/database",
|
"name": "@furtherverse/database",
|
||||||
"version": "0.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"drizzle-orm": "catalog:",
|
"drizzle-orm": "catalog:",
|
||||||
"uuid": "catalog:",
|
"uuid": "catalog:",
|
||||||
|
|||||||
Reference in New Issue
Block a user