Check if vectors is enabled

This commit is contained in:
Alexandre
2025-02-15 09:54:15 +01:00
parent d98b3c77b6
commit 6d7b323412
2 changed files with 17 additions and 1 deletions

View File

@@ -150,6 +150,20 @@ EOF
bashio::log.info "Database setup completed successfully."
}
# Function to check if vectors extension is enabled
check_vector_extension() {
echo "Checking if 'vectors' extension is enabled..."
RESULT=$(psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" -tAc "SELECT extname FROM pg_extension WHERE extname = 'vectors';")
if [[ "$RESULT" == "vectors" ]]; then
echo "✅ 'vectors' extension is enabled."
exit 0
else
bashio::log.warning "❌ 'vectors' extension is NOT enabled."
return 1
fi
}
#########################
# Main script execution #
#########################
@@ -171,3 +185,4 @@ export_db_env
setup_root_user
setup_database
check_vector_extension

View File

@@ -59,7 +59,8 @@ bashio::log.info "Enabling vector.rs"
DB_PORT=5432
DB_HOSTNAME=localhost
DB_PASSWORD="$(bashio::config 'POSTGRES_PASSWORD')"
if bashio::config.has_value "POSTGRES_USER"; then DB_USERNAME="$(bashio::config "POSTGRES_USER")"; else DB_USERNAME=postgres; fi
DB_USERNAME=postgres
if bashio::config.has_value "POSTGRES_USER"; then DB_USERNAME="$(bashio::config "POSTGRES_USER")"; fi
export DB_PORT
export DB_HOSTNAME