Skip to content

feat: add FORCE_SEED env var for manual reseed trigger - #16

Merged
rekabytes merged 1 commit into
mainfrom
dev
Dec 26, 2025
Merged

feat: add FORCE_SEED env var for manual reseed trigger#16
rekabytes merged 1 commit into
mainfrom
dev

Conversation

@rekabytes

@rekabytes rekabytes commented Dec 26, 2025

Copy link
Copy Markdown
Owner
  • Set FORCE_SEED=true in env vars to drop and reseed all food collections
  • Normal mode: skip seeding if data exists (safe for redeployments)
  • Force mode: drop existing data and reseed fresh

📝 Description

Brief description of what this PR does.

🔗 Related Issue

Fixes #(issue number)

🏷️ Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • 🧪 Test update (adding or updating tests)

✅ Checklist

  • I have read the Contributing Guidelines
  • My branch is created from dev (not main)
  • I have run pnpm lint:fix
  • I have run pnpm typecheck
  • I have tested my changes locally
  • My code follows the project's coding standards
  • I have updated documentation (if applicable)

📸 Screenshots (if applicable)

Add screenshots to help explain your changes.

🧪 How to Test

Steps to test this PR:

  1. ...
  2. ...
  3. ...

📝 Additional Notes

Any additional information reviewers should know.

Summary by CodeRabbit

  • New Features

    • Added force seed mode controlled via FORCE_SEED environment variable to enable data reseeding with selective document deletion.
  • Chores

    • Improved startup and completion logging with clearer mode indicators and guidance messages for force seed handling.

✏️ Tip: You can customize this high-level summary in your review settings.

- Set FORCE_SEED=true in env vars to drop and reseed all food collections
- Normal mode: skip seeding if data exists (safe for redeployments)
- Force mode: drop existing data and reseed fresh
@coderabbitai

coderabbitai Bot commented Dec 26, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The seed script now supports a FORCE_SEED environment variable to control reseeding behavior. When enabled, it deletes existing documents in the foods and halal_foods collections before reseeding. In normal mode, it preserves existing data and skips seeding if documents are already present. Logging messages are updated to reflect these scenarios.

Changes

Cohort / File(s) Summary
Seed Script Enhancement
packages/kal-db/scripts/seed-safe.ts
Adds FORCE_SEED environment variable support for controlled reseeding. Implements forceMode flag and conditional deletion logic for foods and halal_foods collections when force mode is active. Updates seeding conditions (shouldSeedFoods, shouldSeedHalal) to combine force mode state with collection counts. Revises startup/completion logs to indicate force-seed scenario and adds reminders to reset FORCE_SEED after deployment. Changes status messaging from "Safe seeding failed" to "Seeding failed".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Oh, a force seed so bright,
Delete old data, reseed with might!
Or preserve what's there, no need to erase,
When FORCE_SEED controls the pace! 🌱

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d218ed6 and 7b769b8.

📒 Files selected for processing (1)
  • packages/kal-db/scripts/seed-safe.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rekabytes
rekabytes merged commit 5ee9083 into main Dec 26, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant