/home/techb158/cosmic-risk.abdallabala.com/prisma
Edit: /home/techb158/cosmic-risk.abdallabala.com/prisma/add-membership.js (997B)
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
(async () => {
const org = await prisma.organization.findUnique({ where: { slug: 'cosmic-demo' } });
if (!org) { console.log('No cosmic-demo org found'); return; }
const ownerRole = await prisma.role.findUnique({ where: { code: 'owner' } });
if (!ownerRole) { console.log('No owner role found'); return; }
for (const email of ['super-owner@cosmic.local', 'super-admin@cosmic.local']) {
const u = await prisma.user.findUnique({ where: { email } });
if (!u) { console.log('User not found:', email); continue; }
await prisma.membership.upsert({
where: { organizationId_userId: { organizationId: org.id, userId: u.id } },
update: { roleId: ownerRole.id, status: 'ACTIVE' },
create: { organizationId: org.id, userId: u.id, roleId: ownerRole.id, status: 'ACTIVE' }
});
console.log('Added', email, 'as member of', org.name);
}
await prisma.$disconnect();
})();