import postgres from "postgres"; const url = process.env.DATABASE_URL; if (!url) { console.error(JSON.stringify({ level: "error", msg: "DATABASE_URL is required" })); process.exit(1); } const sql = postgres(url, { max: 1 }); try { const [existing] = await sql`SELECT id, name FROM households LIMIT 1`; if (existing) { console.log(JSON.stringify({ level: "info", msg: "household exists", name: existing.name })); } else { await sql`INSERT INTO households (name) VALUES ('Home')`; console.log(JSON.stringify({ level: "info", msg: "seeded household Home" })); } } catch (err) { console.error(JSON.stringify({ level: "error", msg: "seed failed", err: String(err) })); process.exit(1); } finally { await sql.end({ timeout: 5 }); }