From 0be1a3525291037338f60aaf02c7bbb27440a298 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Thu, 20 Nov 2025 12:49:52 +0100 Subject: [PATCH] try to fix ci --- frontend/tests/helpers.ts | 2 +- reset_test_data.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 reset_test_data.sh diff --git a/frontend/tests/helpers.ts b/frontend/tests/helpers.ts index c758c46..1c581ed 100644 --- a/frontend/tests/helpers.ts +++ b/frontend/tests/helpers.ts @@ -4,5 +4,5 @@ import { promisify } from 'util'; const execAsync = promisify(exec); export async function resetDatabase(): Promise { - await execAsync('cd .. && ./test_db.sh'); + await execAsync('cd .. && ./reset_test_data.sh'); } diff --git a/reset_test_data.sh b/reset_test_data.sh new file mode 100755 index 0000000..08c8066 --- /dev/null +++ b/reset_test_data.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e + +DB_FILE="db.sqlite" + +# Clear all data and reseed +sqlite3 "$DB_FILE" << 'EOF' +PRAGMA writable_schema = 1; +DELETE FROM sqlite_sequence; +PRAGMA writable_schema = 0; +PRAGMA foreign_keys = OFF; +EOF + +# Get all tables and delete from them +sqlite3 "$DB_FILE" "SELECT 'DELETE FROM ' || name || ';' FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';" | sqlite3 "$DB_FILE" + +# Re-enable foreign keys and reseed +sqlite3 "$DB_FILE" "PRAGMA foreign_keys = ON;" +sqlite3 "$DB_FILE" < seeds.sql