Something went wrong. Try again.
Periodic backups of ATProto repos and blobs safekeeper.dummy.cafe
atproto backup
Something went wrong. Try again.
624 B · 17 lines
TypeScript
at main
123456789101112131415161718import { Database } from 'bun:sqlite';import { drizzle } from 'drizzle-orm/bun-sqlite';import { mkdirSync } from 'node:fs';import { dirname } from 'node:path';import { env } from '../env';import * as schema from './schema';
// Ensure the directory exists before SQLite tries to open the file. Safe to// call on every boot.mkdirSync(dirname(env.DATABASE_PATH), { recursive: true });
const sqlite = new Database(env.DATABASE_PATH, { create: true });sqlite.exec('PRAGMA journal_mode = WAL;');sqlite.exec('PRAGMA foreign_keys = ON;');
const db = drizzle(sqlite, { casing: 'snake_case', schema });export default db;