loopbackio / loopbackio/loopback-next

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

Ouverte
#8,685 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@achrinza y travaille déjà.

Depuis le 26/6/2022.

bug Docs
Langage dominant
TypeScript
Étoiles
5.1k
Forks
1.1k
Merge moyen
2 j 21 h
PR mergées (30 j)
27

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.