loopbackio / loopbackio/loopback-next

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

オープン
#8,685 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

@achrinza がすでに取り組んでいます。

2022年6月26日 から。

bug Docs
主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
2日 21時間
マージ済み PR(30日)
27

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。