loopbackio / loopbackio/loopback-next
npm run migrate : cannot migrate models not attached to this datasource, while having model sequencing in migrate.ts
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
- Visited https://loopback.io/doc/en/lb4/todo-list-tutorial-sqldb.html - #link1
-Visited https://loopback.io/doc/en/lb4/MySQL-connector.html - #link2
## Steps to reproduce
1. Intstall @loopback/authentication @loopback/authentication-jwt extensions
1. Suppose you are using Relational database, using the constraints as foreign keys, so you to sequence the model in migrate.ts as guided on #link1 above like
`models:[...model, ...relatedmodel]`
**Note if you dont have key constraints and this model sequencing, it work fine. no error
1. Then bind the authentication-jwt datasource in to your application.ts
`this.datasource(YourDbDatasource, UserServiceBindings.DATASOURCE_NAME)`
1. when you run migrate.
`
>npm run clean
>npm run build
>npm run migrate
`
Error Come in action
`Cannot migrate database schema Error: Cannot migrate models not attached to this datasource:`
Contributor guide
Research direction
Start with migrate.ts and application.ts, then reproduce the reported failure with npm run clean, npm run build, and npm run migrate after binding the authentication-jwt datasource. Trace why the sequenced models are reported as unattached, and consider the issue done when the documented relational-model setup migrates without that error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100