loopbackio / loopbackio/loopback-next

Cannot migrate database schema error: The associated field "todoListId" in the foreign key constraint does not exist"

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

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

Từ ngày 26/6/2022.

bug Docs
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ả

Describe the bug

What is the problem

When I was doing code practice in the Running on relational databases section, running npm run migrate reported an error:
Cannot migrate database schema error: The associated field "todoListId" in the foreign key constraint does not exist,

The connected DB

Consistent with tutorial - Postgre DB

How I handle it

Change the value of the foreignKey to full lowercase
todo.model.ts

@model({
  settings: {
    postgresql: {
      schema: 'lb4', // schema name
      table: 'todo'  // table name
    },
    foreignKeys: {
      fk_todo_todoListId: {
        name: 'fk_todo_todoListId',
        entity: 'TodoList',
        entityKey: 'id',
        foreignKey: 'todolistid', // The value in the official tutorial is todoListId
      },
    }
  }
})
export class Todo extends Entity { 
// etc
}

Suggestion

Whether the code content should be changed in the tutorial
Transform: foreignKey: 'todoListId' -> foreignKey: 'todolistid'

Logs

No response

Additional information

No response

Reproduction

https://github.com/RokeyJoe/Loopback4-todo-list.git

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.