Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loopback postgresql relation "public.acl"

I am new to loopback and i am just started to implement the tutorial https://docs.strongloop.com/display/public/LB/Connect+your+API+to+a+data+source

But i am receiving the error:

[error: relation "public.acl" does not exist].

I searched a lot for this, but cant find the solution. Please help me to solve this. Thanks..

like image 724
Subburaj Avatar asked Mar 09 '16 07:03

Subburaj


1 Answers

As explained in the doc https://docs.strongloop.com/display/public/LB/Creating+database+tables+for+built-in+models Loopback doesn't automatically migrate (create) tables from models -- that includes built-in models.

So as the link suggests, in order to use other datasource than in-memory db, we should create a separate script server/create-lb-tables.js:

var server = require('./server');
var ds = server.dataSources.postgresDS;
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();
});

where postgresDS is the name of your datasource in server/datasources.json.

Finally, run the script to migrate the tables:

$ cd server
$ node create-lb-tables.js
like image 200
Yohanes Gultom Avatar answered Nov 13 '22 23:11

Yohanes Gultom