Files
jd-book-uploader-backend/scripts/verify_schema.sh
ianshaloom ebeae34e01 Add initial project structure with core functionality for book and stationery uploads
- Created main application entry point in `main.go`.
- Added configuration management in `config/config.go` and tests in `config/config_test.go`.
- Implemented handlers for book and stationery uploads in `handlers/book.go` and `handlers/stationery.go`, including validation logic.
- Established database connection and services in `services/database.go` and `services/book_service.go`.
- Defined models for books and stationery in `models/book.go` and `models/stationery.go`.
- Set up Firebase integration for image uploads in `services/firebase.go`.
- Created migration scripts for database schema in `migrations/001_create_tables.sql` and subsequent updates.
- Added CORS and error handling middleware.
- Included comprehensive tests for handlers, services, and utilities.
- Documented API endpoints and usage in `README.md` and migration instructions in `migrations/README.md`.
- Introduced `.gitignore` to exclude unnecessary files and directories.
- Added Go module support with `go.mod` and `go.sum` files.
- Implemented utility functions for slug generation and validation in `utils/slug.go` and `utils/validation.go`.
2025-11-21 08:50:27 +03:00

63 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Load environment variables from .env or .env.local
if [ -f .env ]; then
export $(grep -v '^#' .env | grep -v '^$' | xargs)
elif [ -f .env.local ]; then
export $(grep -v '^#' .env.local | grep -v '^$' | xargs)
else
echo "Error: No .env or .env.local file found"
exit 1
fi
# Check if required variables are set
if [ -z "$DB_HOST" ] || [ -z "$DB_PORT" ] || [ -z "$DB_USER" ] || [ -z "$DB_NAME" ]; then
echo "Error: Required database environment variables not set"
exit 1
fi
echo "Verifying database schema..."
echo "Connecting to: $DB_HOST:$DB_PORT/$DB_NAME as $DB_USER"
echo ""
# Verify books table
echo "=== Checking books table ==="
PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\d books" 2>&1
if [ $? -eq 0 ]; then
echo "✓ books table exists"
else
echo "✗ books table not found"
fi
echo ""
# Verify stationery table
echo "=== Checking stationery table ==="
PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\d stationery" 2>&1
if [ $? -eq 0 ]; then
echo "✓ stationery table exists"
else
echo "✗ stationery table not found"
fi
echo ""
# Verify indexes
echo "=== Checking indexes ==="
PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "
SELECT
tablename,
indexname,
indexdef
FROM pg_indexes
WHERE schemaname = 'public'
AND (tablename = 'books' OR tablename = 'stationery')
ORDER BY tablename, indexname;
" 2>&1
echo ""
echo "Schema verification complete!"