Remove unnecessary length constraints from VARCHAR(N)
columns
#1077
Labels
component/api-server
p2
Non-critical bugs, and features that help organizations to identify and reduce risk
size/M
Medium effort
technical debt
For historical reasons, the database schema still has lots of
VARCHAR(N)
columns, where the length is artificially restricted.It makes sense for values where the maximum length is known (e.g. hashes), but for most columns it doesn't. The constraints in question can cause issues when importing BOMs that contain fields with values longer than what DT can store in its database. Truncating values prior to storage is not a good option.
By focusing on PostgreSQL only, we are no longer limited by the RDBMSes capability to deal with and / or index
TEXT
columns of arbitrary length. Postgres treatsVARCHAR(N)
andTEXT
the same behind the scenes, whereas other RDBMSes treat them differently.Create a database migration that converts
VARCHAR(N)
columns toTEXT
to lift the artificial length constraints.Keep the constraints for columns where the maximum value length is known, e.g.
SHA256
.Note
In order to make the schema changes effective, corresponding
@Size
annotations must be removed from the Java classes as well. Otherwise the Java code will enforce constraints that no longer exist in the database.The text was updated successfully, but these errors were encountered: