From f51664a44d5fd6ac1e4ecd738b720c93d9598173 Mon Sep 17 00:00:00 2001 From: Adrian Luna Date: Mon, 6 Jul 2026 19:27:27 -0400 Subject: [PATCH] fix: check table existence instead of file for SQLite seeding The previous guard (test -f) skipped seeding when the .sqlite file existed but was empty or missing the expected table. Now we attempt a SELECT on cache_entries and only re-seed if it fails. --- scripts/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 359d7ab..0dbb001 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -61,9 +61,9 @@ gum spin --spinner dot --title "Waiting for cluster_state:ok..." -- \ gum spin --spinner dot --title "Installing PHPUnit in PHP container..." -- \ docker exec "$PHP_CONTAINER" sh -c "cd /var/www/cli/ && composer install --no-interaction || composer require --dev phpunit/phpunit --no-interaction" -# SQLite is file-based; create and seed the database file if missing. +# SQLite is file-based; seed the database if the expected table is missing. gum spin --spinner dot --title "Seeding SQLite database..." -- \ - docker exec "$PHP_CONTAINER" sh -c "test -f /var/www/sqlite/valkeyglide.sqlite || sqlite3 /var/www/sqlite/valkeyglide.sqlite < /var/www/databases-sqlite.sql" + docker exec "$PHP_CONTAINER" sh -c "sqlite3 /var/www/sqlite/valkeyglide.sqlite 'SELECT 1 FROM cache_entries LIMIT 1' 2>/dev/null || sqlite3 /var/www/sqlite/valkeyglide.sqlite < /var/www/databases-sqlite.sql" gum style --foreground 42 "Stack is up." echo