Skip to content

Commit 90b80b1

Browse files
checking if tables are emoty to run seeding
1 parent eefcad6 commit 90b80b1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/deploy.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,24 @@ jobs:
198198
exit 1
199199
fi
200200
201-
# Run migrations
202-
docker exec $BACKEND_CONTAINER php artisan migrate:fresh --seed --force
201+
docker exec $BACKEND_CONTAINER php artisan migrate --force
202+
203+
# Check if seeding is needed (if ALL tables are empty)
204+
SEED_NEEDED=$(docker exec $BACKEND_CONTAINER php artisan tinker --execute '
205+
echo (
206+
DB::table("users")->count() === 0 &&
207+
DB::table("elections")->count() === 0 &&
208+
DB::table("counted_votes")->count() === 0
209+
DB::table("malicious_votes")->count() === 0
210+
) ? "true" : "false";
211+
')
212+
213+
if [ "$SEED_NEEDED" = "true" ]; then
214+
echo "Seeding fresh data..."
215+
docker exec $BACKEND_CONTAINER php artisan db:seed --force
216+
else
217+
echo "Database already has data. Skipping seeding."
218+
fi
203219
204220
# If fails, show error logs
205221
if [ $? -ne 0 ]; then

client/src/Utils/axios.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const token = localStorage.getItem('access_token');
44

55
const axiosInstance = axios.create({
66
baseURL: import.meta.env.VITE_API_URL,
7+
headers: {
8+
'Content-Type': 'application/json',
9+
'Accept': 'application/json'
10+
}
711
});
812

913
export default axiosInstance;

0 commit comments

Comments
 (0)