Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation "roles" does not exist #33

Open
eduardo-spagna opened this issue Dec 3, 2019 · 2 comments
Open

Relation "roles" does not exist #33

eduardo-spagna opened this issue Dec 3, 2019 · 2 comments

Comments

@eduardo-spagna
Copy link

I am encountering an error when i try to create a role

app.js:

'adonis-acl/providers/AclProvider' in providers
'adonis-acl/providers/CommandsProvider' in aceProviders
Role: 'Adonis/Acl/Role', Permission: 'Adonis/Acl/Permission' in aliases

model User.js:

...
static get traits() {
    return [
      '@provider:Adonis/Acl/HasPermission',
      '@provider:Adonis/Acl/HasRole',
    ];
  }
...

roles.js

// Models
const User = use('App/Models/User');
const Role = use('Role');

async function setRoles() {
  const roleAdmin = new Role();
  roleAdmin.name = 'Administrator';
  roleAdmin.slug = 'administrator';
  roleAdmin.description = 'manage administration privileges';
  await roleAdmin.save();

  console.log(roleAdmin);

  const user = await User.find(1);
  await user.roles().attach([roleAdmin.id]);
}

module.exports = { setRoles };

ERROR

error: relation "roles" does not exist

@jonaselan
Copy link

do you published the migrations?

node ace acl:setup
# then
node ace migrations:run

@Kledenai
Copy link

The model is located in Adonis/Acl/Role

change to:
const Role = use('Adonis/Acl/Role');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants