-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Api / Fields: Limit constraint name when adding and index to a field #24203
base: main
Are you sure you want to change the base?
Api / Fields: Limit constraint name when adding and index to a field #24203
Conversation
🦋 Changeset detectedLatest commit: 649bf86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 believe the unique
and primary
constraint(s) have the same issue? We should ensure they are all inline.
Not sure 🤔 |
We can probably leave primary and foreign keys alone as they do not seem to have this issue (foreign keys account for it and primary key sets it to PRIMARY).
Ideally we would not, any way we can use the existing index name instead of re-generating it on removal? That way these changes would be backwards compatible and would resolve not being able to remove index names above 60. cc @licitdev |
How can we retrieve the existing constraint name for that field? One of the solutions would be to rely on the |
Hmm, our current schema helper would be the way but do not believe it currently supports retrieving the index name. What if we extract this |
Yeah I think that can actually work. Feel free to adapt this PR 👍 |
Should be ready for review @joselcvarela / @licitdev |
Hi, are there any updates or quickfixes here? i've the same issue:
thx |
Scope
What's changed:
generateIndexName
getDefaultIndexName
to accept amaxLength
to allow configurability on a per db basisis_indexed
no longer returns true when only a unique index is set forMSSQL
andSQLite
Potential Risks / Drawbacks
The utilNo longer applicable with the move to schema helper.getDefaultIndexName
covers the cases when constraint name size is less than 60, but Mysql maximum is 64Therefore, indexes with constraint names between 61 and 64 may not be removed using Directus.
Should we need a migration for this?No longer applicable with the move to schema helper.Review Notes / Questions
generateIndexName
seemed to be the most appropriate, open to suggestionsknex
if the name exceeds the limit we set the entire thing as base64 encoded hash.maxLength
to infinity to ensure backwards compatibilitypg
driver.ALTER COLUMN TYPE
in a transaction is not support per sql: alter column type in transaction not supported cockroachdb/cockroach#49351. This was left to be addressed in a separate issue/PRTODO
Fixes #24202