Merge pull request #444 from 0x0aNL/0x0anl-doc-mysql-fk-order

fix(docs): Specify table creation order method
This commit is contained in:
Diana Lau 2021-04-15 20:34:27 -04:00 committed by GitHub
commit c5e72dbe28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -583,7 +583,14 @@ type, you can:
Foreign key constraints can be defined in the model definition.
**Note**: The order of table creation is important. A referenced table must
exist before creating a foreign key constraint.
exist before creating a foreign key constraint. The order can be specified
using the optional <a href="https://loopback.io/doc/en/lb4/apidocs.repository.schemamigrationoptions.html">`SchemaMigrationOptions`</a> argument of `migrateSchema`:
```
await app.migrateSchema({
models: [ 'Customer', 'Order' ]
});
```
Define your models and the foreign key constraints as follows: