loopbackio / loopbackio/loopback-next

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

Đang mở
#5,997 8 bình luận 1 reaction 1 người được giao Xem trên GitHub

@hacksparrow đang làm issue này rồi.

Từ ngày 28/7/2020.

bug
Ngôn ngữ chính
TypeScript
Star
5.1k
Fork
1.1k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
27

Mô tả

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 ?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.