Skip to content

Drop unique constrain from index

Tetiana Chupryna requested to merge 427095-make-index-not-unique into master

What does this MR do and why?

This is the part of #427095 (closed)

This MR was extracted from !136241 (closed) because the backend part was blocked, but we need this index for other parts of the feature.

In this MR we're removing unique index and replacing with not unique as we're planning to add non-unique values to the table. That's the reason why the down migration is no-op.

Migration

We need to drop UNIQUE constraint from the index.

UP

  gitlab git:(427095-field-for-sbom-component)  rails db:migrate VERSION=20231113171812                                              
main: == [advisory_lock_connection] object_id: 184080, pg_backend_pid: 35202
main: == 20231113171812 DropIndexFromSbomComponents: migrating ======================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.1286s
main: -- indexes(:sbom_components)
main:    -> 0.0038s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- remove_index(:sbom_components, {:algorithm=>:concurrently, :name=>"index_source_package_names_on_component_and_purl"})
main:    -> 0.0019s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0007s
main: -- index_exists?(:sbom_components, [:component_type, :source_package_name, :purl_type], {:name=>"index_source_package_names_on_component_and_purl", :algorithm=>:concurrently})
main:    -> 0.0022s
main: -- add_index(:sbom_components, [:component_type, :source_package_name, :purl_type], {:name=>"index_source_package_names_on_component_and_purl", :algorithm=>:concurrently})
main:    -> 0.0017s
main: == 20231113171812 DropIndexFromSbomComponents: migrated (0.1601s) =============

main: == [advisory_lock_connection] object_id: 184080, pg_backend_pid: 35202

DOWN

  gitlab git:(427095-field-for-sbom-component)  rails db:rollback:main VERSION=20231113171812
main: == [advisory_lock_connection] object_id: 183700, pg_backend_pid: 36208
main: == 20231113171812 DropIndexFromSbomComponents: reverting ======================
main: == 20231113171812 DropIndexFromSbomComponents: reverted (0.0045s) =============

main: == [advisory_lock_connection] object_id: 183700, pg_backend_pid: 36208

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #427095 (closed)

Edited by Tetiana Chupryna

Merge request reports