Git history was lost when the previous Gitea instance was wiped and reinstalled due to an unresolved corruption bug — this commit is the last known-good file content, exported before the reinstall. Prior commit history is not recoverable through this path.
16 lines
516 B
TypeScript
16 lines
516 B
TypeScript
import Database from "better-sqlite3";
|
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
import path from "node:path";
|
|
import fs from "node:fs";
|
|
import * as schema from "./schema";
|
|
|
|
const dataDir = process.env.DATA_DIR ?? path.join(process.cwd(), "data");
|
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
|
|
const sqlite = new Database(path.join(dataDir, "db.sqlite"));
|
|
sqlite.pragma("journal_mode = WAL");
|
|
sqlite.pragma("foreign_keys = ON");
|
|
|
|
export const db = drizzle(sqlite, { schema });
|
|
export type DB = typeof db;
|