StrongLoop ACL table doesn't exist
Asked Answered
U

3

5

I succeed to generate all my models from my database. Then, I run the api by executing, 'node .' I'm able to see all my web services but when I try to try out a service, there is an 500 error saying to me that There is no ACL table. So, I open model-config.json and I saw that there were 4 models I didn't created before (User, AccessToken, ACL, RoleMapping and Role). I would like to know if all these models has to exist in my database. And Do you know which properties I have to put in each table? Thanks you in advance.

Error:
{
  "error": {
    "name": "Error",
    "status": 500,
    "message": "ER_NO_SUCH_TABLE: Table 'sed.ACL' doesn't exist",
    "code": "ER_NO_SUCH_TABLE",
    "errno": 1146,
    "sqlState": "42S02",
    "index": 0,
    "stack": "Error: ER_NO_SUCH_TABLE: Table 'sed.ACL' doesn't exist\n [...]"
  }
}
Upswell answered 9/9, 2015 at 18:45 Comment(0)
A
5

You will need to automigrate these tables yourself. See:

Andorra answered 9/9, 2015 at 22:11 Comment(0)
R
5

You need to migrate them yourself

  1. Follow the basic procedure in Attaching models to data sources to change from the in-memory data source to the database you want to use.
  2. Create server/create-lb-tables.js file with the following:

var server = require('./server'); var ds = server.dataSources.db; var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role']; ds.automigrate(lbTables, function(er) { if (er) throw er; console.log('Loopback tables [' - lbTables - '] created in ', ds.adapter.name); ds.disconnect(); });

  1. Run the script manually:

$ cd server

$ node create-lb-tables.js

For further details see loopback Documentation

Replace answered 29/12, 2016 at 10:0 Comment(1)
As on October 5, this works, thanks. I think it should be added the fact that in your step 2, second line, server.dataSources.db, this last db attribute refers to the name of the attribute "name" of the json "db" in datasources.jsonFatherly
K
0
var server = require('./server');
    var ds = server.dataSources.db;
    var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
    ds.automigrate(lbTables, function(er) {
        if (er) throw er;
        console.log('Loopback tables [' - lbTables - '] created in ', ds.adapter.name);
        ds.disconnect();
    });

Here var ds = server.dataSources.db;

db would be your database name, which you are using in datasource.json .

database connection string:

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "inventory": {
    "host": "localhost",
    "port": 3306,
    "url": "",
    "database": "inventory",
    "password": "root",
    "name": "inventory",
    "user": "root",
    "connector": "mysql"
  }
}

Here is my db name:

"database": "inventory"

Upadated code is

var server = require('./server');
    var ds = server.dataSources.inventory;
    var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
    ds.automigrate(lbTables, function(er) {
        if (er) throw er;
        console.log('Loopback tables [' - lbTables - '] created in ', ds.adapter.name);
        ds.disconnect();
    });

shoot this code with independent saved file in directory with node filename.js And it works.

Kurr answered 6/1, 2019 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.