28 lines
1.0 KiB
Bash
Executable File
28 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================================
|
|
# Re-seed the forms library after adding new PDFs.
|
|
# Drop PDFs into seeds/forms/ then run: ./seed-forms.sh
|
|
# ============================================================
|
|
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
|
|
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
|
|
|
FORMS_COUNT=$(ls seeds/forms/*.pdf 2>/dev/null | wc -l | tr -d ' ')
|
|
if [ "$FORMS_COUNT" -eq 0 ]; then
|
|
echo -e "${YELLOW}No PDF files found in seeds/forms/ — nothing to seed.${NC}"
|
|
exit 0
|
|
fi
|
|
|
|
echo -e "${GREEN}▶ Seeding $FORMS_COUNT forms into database...${NC}"
|
|
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/teressa" \
|
|
npx tsx scripts/seed-forms.ts 2>&1 | tail -2
|
|
|
|
echo -e "${GREEN}▶ Copying forms into container...${NC}"
|
|
docker compose exec app mkdir -p /app/seeds/forms 2>/dev/null || true
|
|
docker cp seeds/forms/. "$(docker compose ps -q app)":/app/seeds/forms/
|
|
docker compose exec app chown -R nextjs:nodejs /app/seeds/forms/ 2>/dev/null || true
|
|
|
|
echo -e "${GREEN}✓ Done — forms available in the app.${NC}"
|