fix: entrypoint seed check handles empty databases

Check for content entries, not just file existence. If data.db
exists but has no content, still run seed to populate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kunthawat Greethong
2026-04-30 20:24:30 +07:00
parent f981f1fe4c
commit a7ba7c81a1

View File

@@ -1,10 +1,11 @@
#!/bin/sh #!/bin/sh
# Only seed on first launch (when data.db doesn't exist) # Only seed on first launch (when data.db doesn't exist or is empty)
if [ ! -f data.db ]; then # Check if content table has any entries
echo "Database missing, running emdash init & seed..." if [ ! -f data.db ] || ! sqlite3 data.db "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
echo "Database missing or empty, running emdash init & seed..."
pnpm exec emdash init pnpm exec emdash init
pnpm exec emdash seed pnpm exec emdash seed
else else
echo "Database exists, starting normally..." echo "Database exists with content, starting normally..."
fi fi
exec node ./dist/server/entry.mjs exec node ./dist/server/entry.mjs