up stuff
This commit is contained in:
parent
656c3fd414
commit
1c17b57d8a
37 changed files with 2818 additions and 469 deletions
42
test_table_permissions.sh
Executable file
42
test_table_permissions.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
# Script to test permissions on the events table
|
||||
|
||||
# Load environment variables from .env file
|
||||
if [ -f .env ]; then
|
||||
echo "Loading environment variables from .env file..."
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
fi
|
||||
|
||||
# Default values if not set in .env
|
||||
DB_NAME=${DB_NAME:-"oedb"}
|
||||
DB_USER=${DB_USER:-"postgres"}
|
||||
DB_HOST=${DB_HOST:-"localhost"}
|
||||
|
||||
# Set PGPASSWORD for authentication
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
|
||||
echo "Testing permissions on the events table for user '${DB_USER}'..."
|
||||
|
||||
# Try to select from the events table
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT COUNT(*) FROM events;"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Success! User '${DB_USER}' has permission to access the events table."
|
||||
else
|
||||
echo "❌ Error: User '${DB_USER}' does not have permission to access the events table."
|
||||
echo "Running setup_db.sh to fix permissions..."
|
||||
./setup_db.sh
|
||||
|
||||
# Test again after running setup_db.sh
|
||||
echo "Testing permissions again..."
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h $DB_HOST -U $DB_USER -d $DB_NAME -c "SELECT COUNT(*) FROM events;"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Success! Permissions fixed. User '${DB_USER}' now has access to the events table."
|
||||
else
|
||||
echo "❌ Error: Still unable to access the events table. Please check database configuration."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Test completed."
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue