-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automigrate & Autoupdate should use async.eachSeries #168
Comments
Related to: loopbackio/loopback-next#2831 @bajtos, do you think the proposal from @klassicd is something we could try? Thanks. |
Please replace async.each with async.eachSeries! It took me days to find out why I got deadlocks at every automigration. If the order is not kept, complex FOREIGN KEY constructs with postgres are impossible. :( |
I've submitted a patch here #170 I would also like to bring forth another issue I'm running into with the Imagine two tables with a foreign key constraint. If you want to preserve existing data, or the tables don't exist yet, you need need supply A before B in the
If you want to drop all existing data, then you need to supply B before A, otherwise you will get a foreign key constraint error trying to drop A first.
This may be a good case requirement for the migration framework in planning loopbackio/loopback-next#487 My current solution is to look for |
It should be noted that this fixes two of the One example is a PR I have to fix the order of MSSQL alterTable: Rather than waiting for the community to gradually fix these one-by-one, I'd recommend the loopback team seek them out and fix them all. |
Suggestion
I'm running into issues with Loopback 4's
migrateSchema()
where it doesn't create tables in a predictable order. The docs indicate you can specify the order tables are created for Postgres: https://loopback.io/doc/en/lb4/todo-list-tutorial-sqldb.htmlIn my testing both automigrate() & autoupdate() use
async.each
which runs queries in parallel. I believe these should be rewritten to useasync.eachSeries
.https://github.com/strongloop/loopback-connector/blob/master/lib/sql.js#L78
https://github.com/strongloop/loopback-connector/blob/master/lib/sql.js#L1607
Use Cases
Run table migrations in predictable order to eliminate missing relationship errors like
relation "public.relationalTableName" does not exist
. I believe this could be as simple as rewritingasync.each
to beasync.eachSeries
.I'm happy to submit a PR if the maintainers thought this was an acceptable solution.
Acceptance criteria
TBD - will be filled by the team.
The text was updated successfully, but these errors were encountered: