You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i have an issue maybe someone can help me, i can't figure out why my ace command can't access my database.
Here is my command:
import { BaseCommand } from '@adonisjs/core/ace'
import type { CommandOptions } from '@adonisjs/core/types/ace'
import Role from '#models/role'
import Permission from '#models/permission'
import User from '#models/user'
export default class CreateSuperAdmin extends BaseCommand {
static commandName = 'create:super-admin'
static description = 'Create SUPERADMIN user with all permissions'
static options: CommandOptions = {
startApp: true
}
async run() {
this.logger.info('Creating super admin...')
let superAdminRole = await Role.findBy('name', 'SUPERADMIN')
console.log(superAdminRole)
if (!superAdminRole) {
superAdminRole = await Role.create({ name: 'SUPERADMIN', description: 'Super Admin Role' })
const permissions = await Permission.all()
await superAdminRole.related('permissions').attach(permissions.map(permission => permission.id))
this.logger.info('Le rôle SUPERADMIN a été créé avec toutes les permissions.')
} else {
this.logger.info('Le rôle SUPERADMIN existe déjà.')
}
const superUser = await User.create({
username: 'superadmin',
email: 'superadmin@example.com',
password: process.env.SU_PWD,
is_verified: true,
})
await superUser.related('roles').attach([superAdminRole.id])
this.logger.info('Le super utilisateur a été créé avec succès.')
}
}
J'ai donc l'erreur:
$ node ace create:super-admin
[ info ] Creating super admin...
Error: getaddrinfo EAI_AGAIN db
Do i do something wrong here ? Am I missing something ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, i have an issue maybe someone can help me, i can't figure out why my ace command can't access my database.
Here is my command:
J'ai donc l'erreur:
Do i do something wrong here ? Am I missing something ?
Thanks for your time :)
Beta Was this translation helpful? Give feedback.
All reactions