import { NodePgDatabase } from 'drizzle-orm/node-postgres';
import * as schema from '../index';
import {  roles, } from '../index';


export async function seedAdminRole(db: NodePgDatabase<typeof schema>) {
  console.log('Seeding admin role...');

  // Insert roles
  const roleNames = ['superadmin', 'admin', 'autoridad','manager','user','producers','organization'];
  
  for (const roleName of roleNames) {
    try {
      await db.insert(roles).values({
        name: roleName
      }).onConflictDoNothing();
      console.log(`Role '${roleName}' created or already exists`);
    } catch (error) {
      console.error(`Error creating role '${roleName}':`, error);
    }
  }

  console.log('roles seeded successfully');
}
