-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAMA-46 correcting the names of the message_status & file collections (…
…#75) * SAMA-46 add migration for renaming collections * SAMA-46 fiexd test, rename PushEvent model * SAMA-46 add migration: drop old_users collection
- Loading branch information
1 parent
e5f3f6d
commit b71eb08
Showing
9 changed files
with
64 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
migrations/20231019132828-rename-file-message-status-collection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export const up = async (db, client) => { | ||
// vv CREATE MESSAGE STATUSES vv // | ||
let indexes = await db.collection("message_status").indexes(); | ||
indexes = indexes.filter(({ name }) => name !== "_id_"); | ||
|
||
indexes = indexes.map((index) => { | ||
const { v, key, ...options } = index; | ||
return { key, options }; | ||
}); | ||
|
||
const newCollection = await db.createCollection("message_statuses"); | ||
for (const { key, options } of indexes) { | ||
await newCollection.createIndex(key, options); | ||
} | ||
|
||
// vv COPY MESSAGE STATUSES vv // | ||
await db | ||
.collection("message_status") | ||
.aggregate([{ $out: "message_statuses" }]) | ||
.toArray(); | ||
|
||
// vv DROP MESSAGE STATUSES vv // | ||
await db.collection("message_status").drop(); | ||
|
||
// vv FILES vv // | ||
await db.createCollection("files"); | ||
await db | ||
.collection("file") | ||
.aggregate([{ $out: "files" }]) | ||
.toArray(); | ||
await db.collection("file").drop(); | ||
}; | ||
|
||
export const down = async (db, client) => { | ||
await db | ||
.collection("message_statuses") | ||
.rename("message_status", { dropTarget: true }); | ||
await db.collection("files").rename("file", { dropTarget: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const up = async (db, client) => { | ||
await db.collection("old_users").drop(); | ||
}; | ||
|
||
export const down = async (db, client) => { | ||
await db.createCollection("old_users"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,21 +608,21 @@ describe("Contacts functions", async () => { | |
first_name: "Name11_6", | ||
last_name: "Surname11_6", | ||
company: "UserCompany", | ||
email: [{ type: "work", value: "test_matched_6_email" }], | ||
email: [{ type: "work", value: "[email protected]" }], | ||
phone: [{ type: "home", value: "test_6_phone" }], | ||
}, | ||
{ | ||
first_name: "Name22_6", | ||
last_name: "Surname22_6", | ||
company: "UserCompany", | ||
email: [{ type: "work", value: "test_matched_6_email" }], | ||
email: [{ type: "work", value: "[email protected]" }], | ||
phone: [{ type: "home", value: "test_6_phone" }], | ||
}, | ||
{ | ||
first_name: "Name33_6", | ||
last_name: "Surname33_6", | ||
company: "UserCompany", | ||
email: [{ type: "work", value: "test_matched_6_email" }], | ||
email: [{ type: "work", value: "[email protected]" }], | ||
phone: [{ type: "home", value: "test_6_phone" }], | ||
}, | ||
], | ||
|
@@ -641,7 +641,7 @@ describe("Contacts functions", async () => { | |
requestData = { | ||
request: { | ||
user_edit: { | ||
email: "test_matched_6_email", | ||
email: "[email protected]", | ||
phone: "test_6_phone", | ||
}, | ||
id: "1", | ||
|
@@ -666,6 +666,7 @@ describe("Contacts functions", async () => { | |
mockedWS, | ||
requestData | ||
); | ||
console.log(responseData.response.contacts[0]); | ||
|
||
assert.strictEqual(requestData.request.id, responseData.response.id); | ||
assert.strictEqual( | ||
|
@@ -702,7 +703,7 @@ describe("Contacts functions", async () => { | |
let requestData = { | ||
request: { | ||
user_edit: { | ||
email: "test_matched_7_email", | ||
email: "[email protected]", | ||
}, | ||
id: "1", | ||
}, | ||
|
@@ -730,15 +731,15 @@ describe("Contacts functions", async () => { | |
assert.strictEqual(requestData.request.id, responseData.response.id); | ||
assert.strictEqual( | ||
responseData.response.contacts[0].email[0].value, | ||
"test_matched_7_email" | ||
"[email protected]" | ||
); | ||
assert.strictEqual( | ||
responseData.response.contacts[1].email[0].value, | ||
"test_matched_7_email" | ||
"[email protected]" | ||
); | ||
assert.strictEqual( | ||
responseData.response.contacts[2].email[0].value, | ||
"test_matched_7_email" | ||
"[email protected]" | ||
); | ||
assert.strictEqual( | ||
responseData.response.contacts[0].email[0].matched_user_id, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,7 +409,7 @@ describe("User cycle", async () => { | |
user_create: { | ||
login: "login_12345", | ||
password: "new_pasw31", | ||
email: "copy_email", | ||
email: "[email protected]", | ||
phone: "copy_phone", | ||
deviceId: "pc", | ||
}, | ||
|
@@ -449,7 +449,7 @@ describe("User cycle", async () => { | |
const requestData = { | ||
request: { | ||
user_edit: { | ||
email: "copy_email", | ||
email: "[email protected]", | ||
}, | ||
id: "5_1", | ||
}, | ||
|