feat(scripts): add migrate-contribution-amount

This commit is contained in:
Jennie Robinson Faber 2026-04-19 18:31:49 +01:00
parent 74ea932cd2
commit 4c8aff34bf
2 changed files with 90 additions and 0 deletions

View file

@ -49,3 +49,26 @@ If something goes wrong mid-run, the backup JSON contains the pre-migration stat
- Identify which members had `helcimSubscriptionId` before it was unset.
Backup files are gitignored (`.migration-backup-*.json`).
---
## migrate-contribution-amount.cjs
One-time migration: converts `Member.contributionTier` (String enum) to
`Member.contributionAmount` (Number). Idempotent — only touches documents that
still have the legacy field.
### Usage
```bash
node scripts/migrate-contribution-amount.cjs # dry-run
node scripts/migrate-contribution-amount.cjs --apply # write
```
### What it does
Iterates members with `contributionTier` still set, parses each value as an integer
(valid: `"0"`, `"5"`, `"15"`, `"30"`, `"50"`), and writes the converted value to
`contributionAmount`. Unsets the old field. Skips any record that cannot be parsed.
Safe to re-run: only matches members where `contributionTier` still exists.