Skip to content

Commit 486b489

Browse files
Merge pull request #2135 from AletheiaFact/Migrating-to-correct-source-channel-for-some-verification-requests
Migrating to correct source channel for some verification requests
2 parents 5156f73 + ed910e1 commit 486b489

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Db } from "mongodb";
2+
3+
export async function up(db: Db) {
4+
const filter = {
5+
heardFrom: { $regex: /^Automated Monitoring -/i },
6+
sourceChannel: { $ne: "automated_monitoring" },
7+
};
8+
9+
const update = {
10+
$set: { sourceChannel: "automated_monitoring" },
11+
};
12+
13+
const result = await db
14+
.collection("verificationrequests")
15+
.updateMany(filter, update);
16+
17+
console.log(`✅ Updated ${result.modifiedCount} verification requests`);
18+
}
19+
20+
export async function down(db: Db) {
21+
/**
22+
* NO-OP: This migration is irreversible via script.
23+
* Rolling back would incorrectly force all sourceChannel values to "instagram",
24+
* potentially overwriting original historical data.
25+
*/
26+
console.warn('⚠️ Down migration: No action taken (Data correction is irreversible via script).');
27+
}

0 commit comments

Comments
 (0)