Skip to content

Commit 73121cc

Browse files
authored
Merge pull request #3709 from bcgov/feat/3163
chore: delete invalid request data regarding eMOU
2 parents fcfc777 + 73386bd commit 73121cc

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

data-migrations/migrations/20240906172566-populate_account_coding_to_billing2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export const up = async (db, client) => {
2121

2222
for (let x = 0; x < products.length; x++) {
2323
const product = products[x];
24-
let billingId = null;
24+
if (!product.accountCoding) continue;
2525

26+
let billingId = null;
2627
const code = `${product.accountCoding}_${product.provider}`;
2728

2829
const billingDoc = await db.collection('Billing').findOne({ code: { $eq: code } });
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const up = async (db, client) => {
2+
const publicRequests = await db
3+
.collection('PublicCloudRequest')
4+
.find(
5+
{ type: { $ne: 'CREATE' } },
6+
{
7+
projection: { licencePlate: 1 },
8+
sort: { createdAt: 1 },
9+
},
10+
)
11+
.toArray();
12+
13+
for (let x = 0; x < publicRequests.length; x++) {
14+
const request = publicRequests[x];
15+
16+
const query = { licencePlate: { $eq: request.licencePlate } };
17+
18+
const project = await db.collection('PublicCloudProject').findOne(query);
19+
if (!project) {
20+
await db.collection('PublicCloudRequest').deleteMany(query);
21+
await db.collection('PublicCloudRequestedProject').deleteMany(query);
22+
}
23+
}
24+
};
25+
26+
export const down = async (db, client) => {};

0 commit comments

Comments
 (0)