- Add Node.js variant-api server with PostgreSQL integration - Add new utility scripts for system verification and website status - Update CI/CD workflow configuration - Add color variant solution documentation - Add product variants JavaScript support - Update gitignore for new build artifacts
85 lines
2.5 KiB
Bash
Executable File
85 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Comprehensive PostgreSQL Database Verification and Repair Script for SkyArtShop
|
|
|
|
echo "================================================"
|
|
echo "PostgreSQL Database Verification - SkyArtShop"
|
|
echo "================================================"
|
|
echo ""
|
|
|
|
# 1. Check PostgreSQL Service
|
|
echo "[1] Checking PostgreSQL Service..."
|
|
sudo systemctl status postgresql --no-pager | grep -E "Active|loaded"
|
|
echo ""
|
|
|
|
# 2. Check all table structures
|
|
echo "[2] Table Structures and Row Counts..."
|
|
sudo -u postgres psql -d skyartshop << 'EOF'
|
|
SELECT
|
|
tablename,
|
|
(SELECT COUNT(*) FROM pg_indexes WHERE pg_indexes.tablename = pg_tables.tablename) as index_count,
|
|
(SELECT string_agg(indexname, ', ') FROM pg_indexes WHERE pg_indexes.tablename = pg_tables.tablename) as indices
|
|
FROM pg_tables
|
|
WHERE schemaname='public'
|
|
ORDER BY tablename;
|
|
EOF
|
|
echo ""
|
|
|
|
# 3. Check for any locks or blocking queries
|
|
echo "[3] Checking for Active Connections and Locks..."
|
|
sudo -u postgres psql -d skyartshop << 'EOF'
|
|
SELECT pid, usename, application_name, query, query_start
|
|
FROM pg_stat_activity
|
|
WHERE datname='skyartshop' AND state != 'idle'
|
|
ORDER BY query_start DESC;
|
|
EOF
|
|
echo ""
|
|
|
|
# 4. Check schema integrity
|
|
echo "[4] Checking Foreign Key Constraints..."
|
|
sudo -u postgres psql -d skyartshop << 'EOF'
|
|
SELECT
|
|
constraint_name,
|
|
table_name,
|
|
column_name,
|
|
referenced_table_name,
|
|
referenced_column_name
|
|
FROM information_schema.referential_constraints rc
|
|
JOIN information_schema.key_column_usage kcu
|
|
ON rc.constraint_name = kcu.constraint_name
|
|
WHERE constraint_schema='public'
|
|
ORDER BY table_name;
|
|
EOF
|
|
echo ""
|
|
|
|
# 5. Check permissions
|
|
echo "[5] Checking User Permissions..."
|
|
sudo -u postgres psql -d skyartshop << 'EOF'
|
|
SELECT grantee, privilege_type, table_name
|
|
FROM information_schema.table_privileges
|
|
WHERE grantee='skyartapp'
|
|
ORDER BY table_name, privilege_type;
|
|
EOF
|
|
echo ""
|
|
|
|
# 6. Test application user connection
|
|
echo "[6] Testing skyartapp User Connection..."
|
|
PGPASSWORD='SkyArt2025Pass!' psql -h localhost -U skyartapp -d skyartshop -c "SELECT version();" 2>&1 | head -5
|
|
echo ""
|
|
|
|
# 7. Check table sizes
|
|
echo "[7] Table Sizes..."
|
|
sudo -u postgres psql -d skyartshop << 'EOF'
|
|
SELECT
|
|
tablename,
|
|
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as size
|
|
FROM pg_tables
|
|
WHERE schemaname='public'
|
|
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
|
|
EOF
|
|
echo ""
|
|
|
|
echo "================================================"
|
|
echo "Verification Complete"
|
|
echo "================================================"
|