-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
346f6c5
commit f153425
Showing
4 changed files
with
51 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const cuid = require("cuid"); | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function populateUserItemIds() { | ||
const userItems = await prisma.user_item.findMany({ | ||
where: { | ||
id: null, | ||
}, | ||
}); | ||
|
||
for (const userItem of userItems) { | ||
await prisma.user_item.update({ | ||
where: { | ||
item_id_user_id: { | ||
item_id: userItem.item_id, | ||
user_id: userItem.user_id, | ||
}, | ||
}, | ||
data: { | ||
id: cuid(), | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
const main = async () => { | ||
populateUserItemIds(); | ||
prisma | ||
.$disconnect() | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}) | ||
.finally(async () => { | ||
await prisma.$disconnect(); | ||
}); | ||
}; | ||
|
||
main(); |
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