Skip to content
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

Remove unnecessary length constraints from VARCHAR(N) columns #579

Merged
merged 15 commits into from
Feb 22, 2024

Conversation

sahibamittal
Copy link
Collaborator

@sahibamittal sahibamittal commented Feb 15, 2024

Description

Create a database migration that converts VARCHAR(N) columns to TEXT to lift the artificial length constraints.
Keep the constraints for columns where the maximum value length is known, e.g. SHA256.

Addressed Issue

Closes DependencyTrack/hyades#1077

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

@sahibamittal sahibamittal marked this pull request as ready for review February 16, 2024 17:33
@nscuro nscuro added this to the 5.4.0 milestone Feb 19, 2024
Copy link
Member

@nscuro nscuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Some additional changes are needed (inclusion of the new changelog file), and some are to be discussed I guess (whether or not to convert columns holding enum values to TEXT as well).

Sorry for the many comments.

In some model classes there are attempts to truncate strings in order to fit the previously used length constraints, e.g.:

public void setGroup(String group) {
this.group = StringUtils.abbreviate(group, 255);
}

In order to get actual use out of this change, those abbreviate calls should also be removed.

src/main/java/org/dependencytrack/model/Analysis.java Outdated Show resolved Hide resolved
src/main/java/org/dependencytrack/model/Component.java Outdated Show resolved Hide resolved
src/main/java/org/dependencytrack/model/WorkflowState.java Outdated Show resolved Hide resolved
src/main/java/org/dependencytrack/model/WorkflowState.java Outdated Show resolved Hide resolved
@sahibamittal sahibamittal requested a review from nscuro February 21, 2024 14:28
Copy link
Member

@nscuro nscuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@nscuro nscuro added the enhancement New feature or request label Feb 22, 2024
@nscuro nscuro merged commit 522b31f into main Feb 22, 2024
6 checks passed
@nscuro nscuro deleted the issue-1077-improve-unnecessary-varchar-columns branch February 22, 2024 14:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unnecessary length constraints from VARCHAR(N) columns
2 participants