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
feat: fix multiple bugs related to sync()
and indexes. Add Model.getIndexes()
#14619
Conversation
sync()
and indexes in db2sync()
and indexes in db2, mssql, sqlite
This comment was marked as outdated.
This comment was marked as outdated.
sync()
and indexes in db2, mssql, sqlitesync()
and indexes
sync()
and indexessync()
and indexes. Add Model.getIndexes()
You're going to laugh. I've deadlocked my PRs. One of the tests is failing because DB2 is recreating the table instead of altering it. This isn't a regression, so I'm requesting to force-merge this PR, and continue over at #14572 |
Can we temporarily disable the failing unit tests so only DB2 checks fail for this PR and re-enable them in the other PR? Not a fan of force merging Will review tomorrow |
I fixed them, these weren't supposed to fail. Edit: looks like all remaining tests are flaky. I guess we're good to go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always surprised by how much you know about the library and in which corners you can stir :)
Let me handle the merging of this PR, I'll add a detailed message for the changelog |
🎉 This PR is included in version 7.0.0-alpha.14 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Pull Request Checklist
yarn test
oryarn test-DIALECT
pass with this change (including linting)?Description Of Change
Closes #12889
This PR fixes the following bugs:
indexes
option on a model, then callingsync()
, the dialect would modify the model to mark all attributes that are part of the index as unique. (DB2 only)sync({ alter: true })
with an attribute that hasunique: true
set would generate a query such asALTER TABLE users ALTER COLUMN emails SET VARCHAR UNIQUE
. DB2 and MSSQL do not allowUNIQUE
to be specified there. This has been changed to use a separateCREATE INDEX
query.CREATE TABLE
, but that name is ignored by sqlite. Causing subsequentsync()
to try to recreate the index. The firstsync
does not try to create the index as part ofCREATE TABLE
anymore, but executesCREATE INDEX
afterwards to create them (sqlite only, other dialects still do it duringCREATE TABLE
).Model.getIndexes()
which lists all indexes defined on the model (it regroups all indexes, the ones defined throughModelOptions.indexes
, as well as the ones coming fromModelAttributeColumnOptions.unique
)This PR blocks #14572 (comment)
TODO
sync(alter)
tests for adding unique constraints after the firstsync()