loopbackio / loopbackio/loopback-next

Adding a new datasource not used make fail "npm run migrate" if models are given as property

Open
#5,997 8 comments 1 reaction 1 assignee View on GitHub

@hacksparrow is already working on this.

Since Jul 28, 2020.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Steps to reproduce

  1. Create multiple model with foreign key like in the documentation tutorial :
    https://loopback.io/doc/en/lb4/todo-list-tutorial-sqldb.html#database-migration-using-npm-run-migrate-command
  2. Update the migrate.js file with a models property to change the order of table creation (as writting in the tutorial)
    image
  3. run npm run build
  4. run npm run migrate

Current Behavior

I get this error:

Cannot migrate database schema Error: Cannot migrate models not attached to this data source: User Status Logs Queue"

Expected Behavior

To migrate well.

Additional information

  • If I remove the "models" property + removing the foreign keys + run npm run migrate => it's working.
  • If I remove the "models" property + I create the table without the foreign keys + run npm run migrate=> it's working.
  • I have 3 different data sources declared in the project but only one is linked in the 4 repositories (It's a MySQL database connector)

There is a screenshot of the behavior:
At first, I run npm run migrate => everything goes well.
Second I add a new Mysql datasource and run npm run migrate again => it fail.

I suppose that it tries to migrate on all datasource instead of only the one referenced in the repositories.

image

Related Issues

Maybe: https://github.com/strongloop/loopback-next/issues/3819 ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.