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