25 lines
601 B
TypeScript
25 lines
601 B
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
import { rolesData } from "../data/roles";
|
|
|
|
export class RoleSeeder {
|
|
constructor(private prisma: PrismaClient) { }
|
|
|
|
async run(): Promise<void> {
|
|
console.log('Seeding roles...');
|
|
|
|
try {
|
|
const newRole = await this.prisma.roles.createMany({
|
|
data: rolesData,
|
|
skipDuplicates: true,
|
|
})
|
|
|
|
console.log('Roles seeded:', rolesData.map(role => role.name).join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('Error seeding roles:', error);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |