Skip to content

Removes pm_package_versions and pm_package_version_licenses

The schema for our package metadata tables changed to ameliorate performance issues. These may now be cleaned up.

Related Merge Request(s)

Add package metadata tables and models (!102794 - merged)

Related Documentation

Dropping a database table

Schema

gitlabhq_development=# \d pm_package_versions
                                        Table "public.pm_package_versions"
    Column     |           Type           | Collation | Nullable |                     Default
---------------+--------------------------+-----------+----------+-------------------------------------------------
 id            | bigint                   |           | not null | nextval('pm_package_versions_id_seq'::regclass)
 pm_package_id | bigint                   |           | not null |
 version       | text                     |           | not null |
 created_at    | timestamp with time zone |           | not null | now()
 updated_at    | timestamp with time zone |           | not null | now()
Indexes:
    "pm_package_versions_pkey" PRIMARY KEY, btree (id)
    "i_pm_package_versions_on_package_id_and_version" UNIQUE, btree (pm_package_id, version)
    "index_pm_package_versions_on_pm_package_id" btree (pm_package_id)
Check constraints:
    "check_2d8a88cfcc" CHECK (char_length(version) <= 255)
Foreign-key constraints:
    "fk_rails_cf94c3e601" FOREIGN KEY (pm_package_id) REFERENCES pm_packages(id) ON DELETE CASCADE
Referenced by:
    TABLE "pm_package_version_licenses" CONSTRAINT "fk_rails_30ddb7f837" FOREIGN KEY (pm_package_version_id) REFERENCES pm_package_versions(id) ON DELETE CASCADE
gitlabhq_development=# \d pm_package_version_licenses
                                            Table "public.pm_package_version_licenses"
        Column         |           Type           | Collation | Nullable |                         Default
-----------------------+--------------------------+-----------+----------+---------------------------------------------------------
 pm_package_version_id | bigint                   |           | not null |
 pm_license_id         | bigint                   |           | not null |
 created_at            | timestamp with time zone |           | not null | now()
 updated_at            | timestamp with time zone |           | not null | now()
 id                    | bigint                   |           | not null | nextval('pm_package_version_licenses_id_seq'::regclass)
Indexes:
    "pm_package_version_licenses_pkey" PRIMARY KEY, btree (id)
    "i_pm_package_version_licenses_join_ids" UNIQUE, btree (pm_package_version_id, pm_license_id)
    "index_pm_package_version_licenses_on_pm_license_id" btree (pm_license_id)
    "index_pm_package_version_licenses_on_pm_package_version_id" btree (pm_package_version_id)
Foreign-key constraints:
    "fk_rails_30ddb7f837" FOREIGN KEY (pm_package_version_id) REFERENCES pm_package_versions(id) ON DELETE CASCADE
    "fk_rails_7520ea026d" FOREIGN KEY (pm_license_id) REFERENCES pm_licenses(id) ON DELETE CASCADE

Implementation Plan

Merge Request 1

  • Remove the application code related to the table, such as models, controllers, and services
  • Remove data cleanup steps from documentation

Merge Request 2

  • In a post-deployment migration, remove the foreign keys from pm_package_versions and pm_package_versions_licenses using the with_lock_retries helper method.
  • In another subsequent post-deployment migration, use drop_table on pm_package_versions and pm_package_versions_licenses.
Edited by Philip Cunningham