refactor: use esm-safe database migrations
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
954faf6c5a
commit
e5aa398e5c
@@ -0,0 +1,21 @@
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { initializeMigrationSqliteDatabase } from "../../src/database/migrate";
|
||||
|
||||
describe("initializeMigrationSqliteDatabase", () => {
|
||||
it("creates a SQLite DB with WAL journal mode", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "bete-migrate-"));
|
||||
const dbPath = join(dir, "test.db");
|
||||
const { sqlite, db } = initializeMigrationSqliteDatabase(dbPath);
|
||||
|
||||
try {
|
||||
expect(db).toBeDefined();
|
||||
expect(sqlite.pragma("journal_mode", { simple: true })).toBe("wal");
|
||||
} finally {
|
||||
sqlite.close();
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user