-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
59 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
54 changes: 0 additions & 54 deletions
54
src/server/db/migrations/20242606_00_tmp_users_to_course.ts
This file was deleted.
Oops, something went wrong.
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,60 @@ | ||
import { Enrolment, User } from '../db/models' | ||
|
||
const run = async () => { | ||
console.log('Creating tmp users') | ||
const tmpAccounts = [ | ||
'4k117746', | ||
'4k117747', | ||
'4k117748', | ||
'4k117749', | ||
'4k117750', | ||
'4k117751', | ||
'4k117752', | ||
'4k117753', | ||
'4k117754', | ||
'4k117755', | ||
'4k117756', | ||
'4k117757', | ||
'4k117758', | ||
'4k117759', | ||
'4k117760', | ||
'4k117761', | ||
'4k117762', | ||
'4k117763', | ||
'4k117764', | ||
'4k117765', | ||
'4k117766', | ||
'4k117767', | ||
'4k117768', | ||
'4k117769', | ||
] | ||
|
||
const chatInstanceId = '16d246ca-f9a5-4bf3-9d6e-824b261193df' | ||
const userPromises = tmpAccounts.map((userId) => { | ||
const user = { | ||
id: userId, | ||
username: userId, | ||
lastName: userId, | ||
} | ||
return User.upsert(user) | ||
}) | ||
|
||
const users = await Promise.all(userPromises) | ||
|
||
console.log(JSON.stringify(users, null, 2)) | ||
|
||
const enrolmentPromises = tmpAccounts.map((userId) => { | ||
const enrolment = { | ||
userId, | ||
chatInstanceId, | ||
} | ||
return Enrolment.upsert(enrolment) | ||
}) | ||
|
||
const enrollments = await Promise.all(enrolmentPromises) | ||
|
||
console.log(JSON.stringify(enrollments, null, 2)) | ||
console.log('Created tmp users') | ||
} | ||
|
||
run() |