Browse Source
- Changed DATABASE_URL in .env.example to use SQLite file. - Modified refresh function calls in AppShell.vue and public.vue to remove unnecessary parameter. - Enhanced run.sh to include seeding script execution. - Improved seed.js to ensure proper SQLite file path resolution and directory creation. - Introduced db-bun.ts for Bun compatibility with SQLite. - Updated db.ts to handle better-sqlite3 integration and path management. - Adjusted paths.ts to ensure reliable package root resolution for production.tags/邮箱功能前置
10 changed files with 56 additions and 14 deletions
@ -1,5 +1,6 @@ |
|||
DATABASE_URL=postgresql://postgres:xxxxxx@localhost:6666/postgres |
|||
|
|||
# Optional: first admin for an empty instance. `bun run db:seed` creates an admin only when no user has role=admin yet (same username/password rules as registration). |
|||
# DATABASE_URL=postgresql://postgres:xxxxxx@localhost:6666/postgres |
|||
DATABASE_URL=file:./db.sqlite |
|||
NITRO_PORT=3399 |
|||
# Optional: first admin for an empty instance. Creates an admin only when no user has role=admin yet (same username/password rules as registration). |
|||
BOOTSTRAP_ADMIN_USERNAME= |
|||
BOOTSTRAP_ADMIN_PASSWORD= |
|||
@ -0,0 +1,21 @@ |
|||
import { drizzle } from "drizzle-orm/bun-sqlite"; |
|||
import { resolveSqliteDatabaseUrl } from "../../lib/resolve-sqlite-url"; |
|||
|
|||
/** |
|||
* Bun 无法加载 better-sqlite3 原生模块;`bun run seed.ts` 等脚本使用本模块。 |
|||
* Nitro/Node 服务端仍用 `db.ts`(better-sqlite3)。 |
|||
*/ |
|||
const rawUrl = process.env.DATABASE_URL; |
|||
if (!rawUrl) { |
|||
throw new Error("DATABASE_URL 未设置"); |
|||
} |
|||
const resolvedUrl = resolveSqliteDatabaseUrl(rawUrl); |
|||
process.env.DATABASE_URL = resolvedUrl; |
|||
|
|||
const sqlitePath = resolvedUrl.startsWith("file:") |
|||
? resolvedUrl.slice("file:".length) |
|||
: resolvedUrl; |
|||
|
|||
const _db = drizzle(sqlitePath); |
|||
|
|||
export { _db as dbGlobal }; |
|||
Binary file not shown.
Loading…
Reference in new issue