refactor: 降级 Drizzle ORM 至 0.45.x 稳定版,对齐 Better Auth 兼容性

- drizzle-orm 1.0.0-beta.15 → 0.45.2, drizzle-kit → 0.31.10
- RQBv2 defineRelations() → 旧版 relations() 回调语法
- drizzle-orm/zod → drizzle-zod 独立包
- auth/schema.ts 改由 Better Auth CLI 生成(bun run db:auth)
- db/schema/index.ts 选择性导出表(不导出生成文件中的旧版 relations)
- 删除 db:push script,强制 db:generate → db:migrate 工作流
- 重建迁移基线(删除旧迁移目录,全新生成初始迁移)
This commit is contained in:
2026-03-31 20:18:15 +08:00
parent 5e65c37a26
commit 6bedc1d60d
19 changed files with 879 additions and 1141 deletions
+3 -3
View File
@@ -10,11 +10,11 @@ export const category = {
.use(authMiddleware)
.handler(async ({ context }) => {
return await context.db.query.category.findMany({
where: { userId: context.user.id },
orderBy: { orderId: 'asc' },
where: (category, { eq }) => eq(category.userId, context.user.id),
orderBy: (category, { asc }) => asc(category.orderId),
with: {
bookmarks: {
orderBy: { orderId: 'asc' },
orderBy: (bookmark, { asc }) => asc(bookmark.orderId),
},
},
})