feat: 迁移数据库至 SQLite 并新增项目文档

- 将 Postgres 数据库替换为 SQLite
- 并同步添加 README 文档以优化项目初始化流程
This commit is contained in:
2026-01-20 16:56:11 +08:00
parent 5513979ebc
commit b967deb4b1
14 changed files with 482 additions and 78 deletions

22
scripts/init-db.ts Normal file
View File

@@ -0,0 +1,22 @@
import { Database } from 'bun:sqlite'
import { mkdir } from 'node:fs/promises'
// Ensure data directory exists
await mkdir('./data', { recursive: true })
const db = new Database('./data/app.db', { create: true })
db.exec('PRAGMA journal_mode = WAL;')
// Create todo table
db.exec(`
CREATE TABLE IF NOT EXISTS todo (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
completed INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
updated_at INTEGER NOT NULL DEFAULT (unixepoch())
);
`)
console.log('Database initialized successfully!')
db.close()