Skip to content

Commit

Permalink
Update insert_db.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored Jan 22, 2024
1 parent de1fce5 commit 7c457ed
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions scripts/insert_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,12 @@ if psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -t -c "$CHECK_TA
echo "Database $PGDATABASE exists with tables."
else
echo "Error: Database $PGDATABASE does not exist or has no tables. Running database migration."
sleep 3

# Find the process running on port 8080 and kill it
PROCESS_ID=$(lsof -i :8080 | awk 'NR==2{print $2}')
if [ -n "$PROCESS_ID" ]; then
kill -INT $PROCESS_ID
echo "Killed process $PROCESS_ID running on port 8080."
else
echo "No process running on port 8080."
exit 0
fi
fi
go run ../backend/src/main.go --only-migrate

# Insert data from data.sql
if psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -a -f "$INSERTSQL" > /dev/null 2>&1; then
echo "Data inserted successfully."
else
echo "Error: Failed to insert data."
exit 1
fi
fi

0 comments on commit 7c457ed

Please sign in to comment.