Skip to content

Remove unused sbom_components.source_package_name in post migration

What does this MR do and why?

This migration completes the process to remove the unused source_package_name column from the sbom_components table. Closes #435733.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

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

Before

gitlabhq_development=# \d sbom_components
                                           Table "public.sbom_components"
       Column        |           Type           | Collation | Nullable |                   Default
---------------------+--------------------------+-----------+----------+---------------------------------------------
 id                  | bigint                   |           | not null | nextval('sbom_components_id_seq'::regclass)
 created_at          | timestamp with time zone |           | not null |
 updated_at          | timestamp with time zone |           | not null |
 component_type      | smallint                 |           | not null |
 name                | text                     |           | not null |
 purl_type           | smallint                 |           |          |
 source_package_name | text                     |           |          |
Indexes:
    "sbom_components_pkey" PRIMARY KEY, btree (id)
    "index_sbom_components_on_component_type_name_and_purl_type" UNIQUE, btree (name, purl_type, component_type)
Check constraints:
    "check_91a8f6ad53" CHECK (char_length(name) <= 255)
    "check_e2dcb53709" CHECK (char_length(source_package_name) <= 255)
Referenced by:
    TABLE "sbom_occurrences" CONSTRAINT "fk_d857c6edc1" FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE
    TABLE "sbom_component_versions" CONSTRAINT "fk_rails_61a83aa892" FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE

After

gitlabhq_development=# \d sbom_components
                                         Table "public.sbom_components"
     Column     |           Type           | Collation | Nullable |                   Default
----------------+--------------------------+-----------+----------+---------------------------------------------
 id             | bigint                   |           | not null | nextval('sbom_components_id_seq'::regclass)
 created_at     | timestamp with time zone |           | not null |
 updated_at     | timestamp with time zone |           | not null |
 component_type | smallint                 |           | not null |
 name           | text                     |           | not null |
 purl_type      | smallint                 |           |          |
Indexes:
    "sbom_components_pkey" PRIMARY KEY, btree (id)
    "index_sbom_components_on_component_type_name_and_purl_type" UNIQUE, btree (name, purl_type, component_type)
Check constraints:
    "check_91a8f6ad53" CHECK (char_length(name) <= 255)
Referenced by:
    TABLE "sbom_occurrences" CONSTRAINT "fk_d857c6edc1" FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE
    TABLE "sbom_component_versions" CONSTRAINT "fk_rails_61a83aa892" FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE

How to set up and validate locally

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

  1. Checkout branch and run bundle exec rails db:migrate
  2. Open up psql and verify that the column is dropped from the table.
  3. Revert migration, and verify that the column and column constraint recreates previous empty column: bundle exec rails db:rollback:main.

Merge request reports