Files
NetAlertX/scripts/db_cleanup/regenerate-database.sh
Adam Outler 30c832b14e move app.
2026-02-07 15:20:49 +00:00

21 lines
665 B
Bash
Executable File

#!/bin/sh
# This script recreates the database from schema code.
# Database location
NETALERTX_DB_FILE=${NETALERTX_DB:-/data/db}/app.db
#remove the old database
rm "${NETALERTX_DB_FILE}"
# Calculate script directory and schema path
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
# Path to the schema file (relative to script location: scripts/db_cleanup/ -> ../../server/db/schema/app.sql)
SCHEMA_FILE="${SCRIPT_DIR}/../../server/db/schema/app.sql"
if [ ! -f "${SCHEMA_FILE}" ]; then
echo "Error: Schema file not found at ${SCHEMA_FILE}"
exit 1
fi
# Import the database schema into the new database file
sqlite3 "${NETALERTX_DB_FILE}" < "${SCHEMA_FILE}"