Add idify lfg match stages script

This commit is contained in:
Kalle 2022-03-17 18:03:45 +02:00
parent 23bbea328c
commit a514617427
2 changed files with 38 additions and 1 deletions

View File

@ -26,7 +26,8 @@
"cy:run": "npx cypress run",
"test:unit": "uvu -r tsm -r tsconfig-paths/register -i cypress",
"tests": "npm run lint:styles && npm run lint:ts && npm run prettier:check && npm run typecheck && npm run test:unit",
"matches": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/matchesWithoutDetails.ts"
"matches": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/matchesWithoutDetails.ts",
"idify": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/idifyLfgMatchStages.ts"
},
"dependencies": {
"@dnd-kit/core": "^5.0.2",

View File

@ -0,0 +1,36 @@
import { PrismaClient } from "@prisma/client";
import { v4 as uuidv4 } from "uuid";
const prisma = new PrismaClient();
async function main() {
const stages = await prisma.lfgGroupMatchStage.findMany({
where: {
id: null,
},
});
console.log("in total: ", stages.length);
let count = 1;
for (const stage of stages) {
await prisma.lfgGroupMatchStage.update({
where: {
lfgGroupMatchId_order: {
lfgGroupMatchId: stage.lfgGroupMatchId,
order: stage.order,
},
},
data: {
id: uuidv4(),
},
});
console.log(count);
count++;
}
}
main()
// eslint-disable-next-line no-console
.then(() => console.log("done"))
.catch((e) => console.error(e));