This commit is contained in:
2026-10-29 13:21:30 +06:00
parent 2ae9f84ddf
commit 3acc0de8de
132 changed files with 35007 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function run() {
const users = await prisma.user.findMany({ select: { id: true } });
const userIds = new Set(users.map((u) => u.id));
console.log('Total valid users in DB:', userIds.size);
const permissions = await prisma.filePermission.findMany();
console.log('Total permissions in DB:', permissions.length);
let orphaned = 0;
for (const p of permissions) {
if (!userIds.has(p.ownerId) || !userIds.has(p.granteeUserId)) {
orphaned++;
await prisma.filePermission.delete({ where: { id: p.id } });
}
}
console.log('Cleaned up orphaned permissions:', orphaned);
await prisma.$disconnect();
}
run().catch((e) => {
console.error(e);
process.exit(1);
});