Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.5.0",
"private": true,
"license": "Apache-2.0",
"description": "CAP Trellis \u2014 open-source client intake, eligibility, case & service management, and CSBG Annual Report 3.0 (OMB 0970-0492) reporting for Community Action Agencies",
"description": "CAP Trellis open-source client intake, eligibility, case & service management, and CSBG Annual Report 3.0 (OMB 0970-0492) reporting for Community Action Agencies",
"repository": {
"type": "git",
"url": "https://github.com/dchevalier18/csbg-intake.git"
Expand All @@ -25,7 +25,7 @@
"uuid": "^11.1.1"
},
"dependencies": {
"@electric-sql/pglite": "^0.3.0",
"@electric-sql/pglite": "^0.5.4",
"drizzle-orm": "^0.45.2",
"exceljs": "^4.4.0",
"next": "^15.5.4",
Expand Down
15 changes: 14 additions & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,20 @@ function createPgliteConn(): Conn {
// PGlite's own mkdir is NOT recursive — a nested data dir (./data/pglite)
// fails with ENOENT unless the parents exist. Create the full path first.
if (dir && dir !== "memory") {
fs.mkdirSync(path.resolve(dir), { recursive: true });
const abs = path.resolve(dir);
fs.mkdirSync(abs, { recursive: true });
// A data dir a crashed instance left PARTIALLY initialized (e.g. killed
// mid-initdb) aborts every later open. A healthy PGlite dir always has a
// PG_VERSION file — quarantine anything non-empty without one (moved
// aside, never deleted) so the engine can initialize fresh.
const entries = fs.readdirSync(abs);
const healthy = entries.includes("PG_VERSION") && entries.includes("postgresql.conf");
if (entries.length > 0 && !healthy) {
const quarantine = `${abs}.corrupt-${new Date().toISOString().replace(/[:.]/g, "-")}`;
fs.renameSync(abs, quarantine);
fs.mkdirSync(abs, { recursive: true });
console.warn(`[db] embedded data dir was partially initialized — moved to ${quarantine} and starting fresh`);
}
}
// single in-process engine — no advisory lock needed (or available across processes);
// embedded mode is for one local server, never for multi-process deployments
Expand Down
Loading