Files
SkyArtShop/backend/run-migration.sh
Local Server 017c6376fc updateweb
2025-12-24 00:13:23 -06:00

30 lines
585 B
Bash
Executable File

#!/bin/bash
# Run database migration as postgres user
MIGRATION_FILE="$1"
if [ -z "$MIGRATION_FILE" ]; then
echo "Usage: ./run-migration.sh <migration-file.sql>"
exit 1
fi
if [ ! -f "$MIGRATION_FILE" ]; then
echo "Error: Migration file not found: $MIGRATION_FILE"
exit 1
fi
echo "🔐 Running migration as database owner..."
echo "📁 Migration file: $MIGRATION_FILE"
echo ""
sudo -u postgres psql -d skyartshop -f "$MIGRATION_FILE"
if [ $? -eq 0 ]; then
echo ""
echo "✅ Migration completed successfully!"
else
echo ""
echo "❌ Migration failed!"
exit 1
fi