up stuff
This commit is contained in:
parent
656c3fd414
commit
1c17b57d8a
37 changed files with 2818 additions and 469 deletions
45
test_permissions.sh
Executable file
45
test_permissions.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
# Script to test database permissions for 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 database permissions for user '$DB_USER'..."
|
||||
echo "Attempting to select from events table..."
|
||||
|
||||
# Try to select from the events table
|
||||
result=$(psql -h $DB_HOST -U $DB_USER -d $DB_NAME -t -c "SELECT COUNT(*) FROM events;")
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Success! User '$DB_USER' has permission to access the events table."
|
||||
echo "Count of events: $result"
|
||||
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..."
|
||||
result=$(psql -h $DB_HOST -U $DB_USER -d $DB_NAME -t -c "SELECT COUNT(*) FROM events;")
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Success! Permissions fixed. User '$DB_USER' now has access to the events table."
|
||||
echo "Count of events: $result"
|
||||
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