require('dotenv').config();
const { PrismaClient } = require('@prisma/client');
const p = new PrismaClient();

(async () => {
  const roles = await p.role.findMany();
  for (const r of roles) {
    if (!r.permissions.includes('DATA_DELETE')) {
      await p.role.update({
        where: { id: r.id },
        data: { permissions: [...r.permissions, 'DATA_DELETE'] }
      });
      console.log('Added DATA_DELETE to: ' + r.name);
    }
  }
  await p.$disconnect();
})();
