loopbackio / loopbackio/loopback-next

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

Aperta
#8,685 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@achrinza ci sta già lavorando.

Dal 26/6/2022.

bug Docs
Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
2g 21h
PR unite (30g)
27

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.