chore(scripts): rename contributionTier → contributionAmount in seed + legacy migration
This commit is contained in:
parent
b17e006d65
commit
9f557d7e7a
3 changed files with 24 additions and 24 deletions
|
|
@ -182,7 +182,7 @@ async function main() {
|
|||
const membersColl = mongoose.connection.collection('members')
|
||||
const rawMembers = await membersColl
|
||||
.find({ helcimSubscriptionId: { $exists: true } })
|
||||
.project({ _id: 1, email: 1, status: 1, helcimSubscriptionId: 1, contributionTier: 1, billingCadence: 1 })
|
||||
.project({ _id: 1, email: 1, status: 1, helcimSubscriptionId: 1, contributionAmount: 1, billingCadence: 1 })
|
||||
.toArray()
|
||||
mongoMembers = rawMembers
|
||||
console.log(`Found ${mongoMembers.length} members`)
|
||||
|
|
@ -347,14 +347,14 @@ async function main() {
|
|||
|
||||
if (!runMongoDestructive) {
|
||||
console.log(` [DRY RUN] Would updateMany on ${mongoMembers.length} members:`)
|
||||
console.log(' { $set: { contributionTier: \'0\', billingCadence: \'monthly\' }, $unset: { helcimSubscriptionId: \'\' } }')
|
||||
console.log(' { $set: { contributionAmount: 0, billingCadence: \'monthly\' }, $unset: { helcimSubscriptionId: \'\' } }')
|
||||
console.log(' (Status field is NOT changed — active stays active, pending_payment stays pending_payment)')
|
||||
} else {
|
||||
console.log(` Running updateMany on ${mongoMembers.length} members with helcimSubscriptionId...`)
|
||||
const result = await membersColl.updateMany(
|
||||
{ helcimSubscriptionId: { $exists: true } },
|
||||
{
|
||||
$set: { contributionTier: '0', billingCadence: 'monthly' },
|
||||
$set: { contributionAmount: 0, billingCadence: 'monthly' },
|
||||
$unset: { helcimSubscriptionId: '' },
|
||||
},
|
||||
{ runValidators: false },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue