Add `component_name` and `input_file_path` columns to sbom_occurrences
What does this MR do and why?
This MR introduces a migration to add component_name
and input_file_path
columns to the sbom_occurrences
table. This is a denormalization to improve the performance of some of the queries. Those queries will be changed in follow-up MR(s).
rake db:migrate:up
main: == [advisory_lock_connection] object_id: 219660, pg_backend_pid: 54119
main: == 20230802124027 AddComponentNameAndInputFilePathToSbomOccurrences: migrating
main: -- transaction_open?()
main: -> 0.0000s
main: -- add_column(:sbom_occurrences, :component_name, :text, {:if_not_exists=>true})
main: -> 0.1528s
main: -- add_column(:sbom_occurrences, :input_file_path, :text, {:if_not_exists=>true})
main: -> 0.0017s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE sbom_occurrences\nADD CONSTRAINT check_9b29021fa8\nCHECK ( char_length(component_name) <= 255 )\nNOT VALID;\n")
main: -> 0.0023s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0013s
main: -- execute("ALTER TABLE sbom_occurrences VALIDATE CONSTRAINT check_9b29021fa8;")
main: -> 0.0031s
main: -- execute("RESET statement_timeout")
main: -> 0.0005s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE sbom_occurrences\nADD CONSTRAINT check_bd1367d4c1\nCHECK ( char_length(input_file_path) <= 255 )\nNOT VALID;\n")
main: -> 0.0006s
main: -- execute("ALTER TABLE sbom_occurrences VALIDATE CONSTRAINT check_bd1367d4c1;")
main: -> 0.0005s
main: == 20230802124027 AddComponentNameAndInputFilePathToSbomOccurrences: migrated (0.2006s)
main: == [advisory_lock_connection] object_id: 219660, pg_backend_pid: 54119
rake db:migrate:down
main: == [advisory_lock_connection] object_id: 220340, pg_backend_pid: 53637
main: == 20230802124027 AddComponentNameAndInputFilePathToSbomOccurrences: reverting
main: -- remove_column(:sbom_occurrences, :component_name, {:if_exists=>true})
main: -> 0.1064s
main: -- remove_column(:sbom_occurrences, :input_file_path, {:if_exists=>true})
main: -> 0.0015s
main: == 20230802124027 AddComponentNameAndInputFilePathToSbomOccurrences: reverted (0.1112s)
main: == [advisory_lock_connection] object_id: 220340, pg_backend_pid: 53637
Related to #419533 (closed), and #419424 (closed)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Mehmet Emin INAC