Fix issue where all sessions were being interpreted as users

main
Ashelyn Dawn 3 years ago
parent 49a88704c9
commit c57d8a01ba

@ -13,14 +13,16 @@ const saveExcelDataFile = require('./tasks/writeExcelSheet')
async function doMigration() {
const items = await oldDB.sock.find().lean().exec()
const users = await oldDB.user.find().populate('purchases').lean().exec()
const carts = users.map(u => u.purchases).flat()
const allUsers = await oldDB.user.find().populate('purchases').lean().exec()
const carts = allUsers.map(u => u.purchases).flat()
const coupons = await oldDB.coupon.find().lean().exec()
console.log(`Loaded ${carts.length} purchases from ${users.length} users`)
const registeredUsers = allUsers.filter(user => user.email)
console.log(`Inserting ${users.length} users into the database`)
const importAdmin = await createUsers(newDB, users);
console.log(`Loaded ${carts.length} purchases and ${registeredUsers.length} users`)
console.log(`Inserting ${registeredUsers.length} users into the database`)
const importAdmin = await createUsers(newDB, registeredUsers);
console.log(` Found user account ${importAdmin.uuid} (${importAdmin.email}) to attribute file uploads to`)
console.log(`\nInserting ${items.length} items into database`)
@ -31,7 +33,7 @@ async function doMigration() {
await uploadImages(newDB, itemImages, importAdmin.uuid)
console.log('\nWriting Excel data file')
await saveExcelDataFile(users, coupons, items, path.join(__dirname, './datafile.xlsx'))
await saveExcelDataFile(allUsers, coupons, items, path.join(__dirname, './datafile.xlsx'))
}
doMigration()

Loading…
Cancel
Save