loopbackio / loopbackio/loopback-next

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

Aperta
#5,997 8 commenti 1 reazione 1 assegnatario Vedi su GitHub

@hacksparrow ci sta già lavorando.

Dal 28/7/2020.

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

Descrizione

## 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](https://user-images.githubusercontent.com/60438474/88308917-eb0d2e80-cd0d-11ea-9a36-b94cdaa1bc76.png)
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](https://user-images.githubusercontent.com/60438474/88311450-2d843a80-cd11-11ea-8331-7143049d9de8.png)

## Related Issues
Maybe: https://github.com/strongloop/loopback-next/issues/3819 ?

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.