4

I tried to create tables from models using code in server.js:

app.datasources['Billing'].automigrate(['Roles', 'Users'], function(err) {
   console.log(err);
});

and got the following error:

[Error: Cannot migrate models not attached to this datasource: Roles Users ]

Indeed I'm not sure which way node creates tables in mysql db but this solution was provided in manual.

Probably someone has a link to any documentation regarding this issue.

Supervision
  • 1,683
  • 1
  • 18
  • 23

2 Answers2

4

Like error message suggests, your models are not attached to "Billing" datasource. Use attachTo() to assign datasource to a model.

app.models.YourModel.attachTo(app.dataSources.Billing);

Also this answer might be helpful

A.Z.
  • 1,638
  • 2
  • 18
  • 27
1

You can look at the file located in YourProject/server/boot/model-config.json and change the dataSource of the model you're using from "db" to the connector you're using.

eg:

Document": {
    "dataSource": "db",
    "public": true
}

to

Document": {
    "dataSource": "mongoDs",
    "public": true
}

where mongoDs is my connector for MongoDB

Enigma297
  • 31
  • 1
  • 7