refactor(db): 适配 drizzle-orm 0.x API 并引入 drizzle-zod

drizzle-orm 从 1.0 beta 降级到 0.45 后,1.0 的 defineRelations、drizzle-orm/zod
子路径以及 RQB v2 的 orderBy 对象语法均不可用。改用 schema 作为 drizzle()
入参、从独立的 drizzle-zod 包导入 schema 生成器,并将 orderBy 改回 0.x 的
回调写法。同时删除因降级而失效的旧迁移。
This commit is contained in:
2026-04-24 20:08:41 +08:00
parent f9847e6f6e
commit 75c77159b4
8 changed files with 8 additions and 103 deletions
@@ -1,7 +0,0 @@
CREATE TABLE "todo" (
"id" uuid PRIMARY KEY,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"title" text NOT NULL,
"completed" boolean DEFAULT false NOT NULL
);
@@ -1,88 +0,0 @@
{
"version": "8",
"dialect": "postgres",
"id": "91ea16cc-3353-493c-bc2c-4fc9dea2fce7",
"prevIds": ["00000000-0000-0000-0000-000000000000"],
"ddl": [
{
"isRlsEnabled": false,
"name": "todo",
"entityType": "tables",
"schema": "public"
},
{
"type": "uuid",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "id",
"entityType": "columns",
"schema": "public",
"table": "todo"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "created_at",
"entityType": "columns",
"schema": "public",
"table": "todo"
},
{
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"name": "updated_at",
"entityType": "columns",
"schema": "public",
"table": "todo"
},
{
"type": "text",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"name": "title",
"entityType": "columns",
"schema": "public",
"table": "todo"
},
{
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "false",
"generated": null,
"identity": null,
"name": "completed",
"entityType": "columns",
"schema": "public",
"table": "todo"
},
{
"columns": ["id"],
"nameExplicit": false,
"name": "todo_pkey",
"schema": "public",
"table": "todo",
"entityType": "pks"
}
],
"renames": []
}