From 65186491d8084b0358dd47a6fd6f063f53634ab7 Mon Sep 17 00:00:00 2001 From: mc_rocha Date: Tue, 23 Sep 2025 14:37:34 -0400 Subject: [PATCH 1/5] Drop software_licenses table Changelog: removed --- db/docs/deleted_tables/software_licenses.yml | 14 ++++++++++ .../20250923165400_drop_software_licenses.rb | 21 +++++++++++++++ db/schema_migrations/20250923165400 | 1 + db/structure.sql | 26 ------------------- 4 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 db/docs/deleted_tables/software_licenses.yml create mode 100644 db/post_migrate/20250923165400_drop_software_licenses.rb create mode 100644 db/schema_migrations/20250923165400 diff --git a/db/docs/deleted_tables/software_licenses.yml b/db/docs/deleted_tables/software_licenses.yml new file mode 100644 index 00000000000000..f8cf88c3694653 --- /dev/null +++ b/db/docs/deleted_tables/software_licenses.yml @@ -0,0 +1,14 @@ +--- +table_name: software_licenses +classes: + - SoftwareLicense +feature_categories: + - security_policy_management +description: Normalized software licenses to use in conjunction with License Compliance + features (like software license policies). Scheduled for removal in https://gitlab.com/gitlab-org/gitlab/-/issues/497969 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6246 +milestone: '11.2' +gitlab_schema: gitlab_main_org +table_size: small +removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/206085 +removed_in_milestone: '18.5' diff --git a/db/post_migrate/20250923165400_drop_software_licenses.rb b/db/post_migrate/20250923165400_drop_software_licenses.rb new file mode 100644 index 00000000000000..a40a63b4e2972d --- /dev/null +++ b/db/post_migrate/20250923165400_drop_software_licenses.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class DropSoftwareLicenses < Gitlab::Database::Migration[2.3] + milestone '18.5' + disable_ddl_transaction! + + def up + drop_table :software_licenses + end + + def down + create_table :software_licenses do |t| + t.string :name, null: false + t.string :spdx_identifier, null: true, limit: 255 + end + + add_concurrent_index :software_licenses, 'LOWER(name)', name: 'idx_software_licenses_lower_name' + add_concurrent_index :software_licenses, :spdx_identifier, name: 'index_software_licenses_on_spdx_identifier' + add_concurrent_index :software_licenses, :name, unique: true, name: 'index_software_licenses_on_unique_name' + end +end diff --git a/db/schema_migrations/20250923165400 b/db/schema_migrations/20250923165400 new file mode 100644 index 00000000000000..01bd3b48121905 --- /dev/null +++ b/db/schema_migrations/20250923165400 @@ -0,0 +1 @@ +b654b4d8c131891fcab94032a8b99a638cb7ab02f916ebc6ef56354348cfc02e \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index cfade9c0c09b1b..64699250c5b77d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -26723,21 +26723,6 @@ CREATE SEQUENCE software_license_policies_id_seq ALTER SEQUENCE software_license_policies_id_seq OWNED BY software_license_policies.id; -CREATE TABLE software_licenses ( - id bigint NOT NULL, - name character varying NOT NULL, - spdx_identifier character varying(255) -); - -CREATE SEQUENCE software_licenses_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE software_licenses_id_seq OWNED BY software_licenses.id; - CREATE TABLE spam_logs ( id bigint NOT NULL, user_id bigint, @@ -32061,8 +32046,6 @@ ALTER TABLE ONLY snippets ALTER COLUMN id SET DEFAULT nextval('snippets_id_seq': ALTER TABLE ONLY software_license_policies ALTER COLUMN id SET DEFAULT nextval('software_license_policies_id_seq'::regclass); -ALTER TABLE ONLY software_licenses ALTER COLUMN id SET DEFAULT nextval('software_licenses_id_seq'::regclass); - ALTER TABLE ONLY spam_logs ALTER COLUMN id SET DEFAULT nextval('spam_logs_id_seq'::regclass); ALTER TABLE ONLY sprints ALTER COLUMN id SET DEFAULT nextval('sprints_id_seq'::regclass); @@ -35678,9 +35661,6 @@ ALTER TABLE ONLY snippets ALTER TABLE ONLY software_license_policies ADD CONSTRAINT software_license_policies_pkey PRIMARY KEY (id); -ALTER TABLE ONLY software_licenses - ADD CONSTRAINT software_licenses_pkey PRIMARY KEY (id); - ALTER TABLE ONLY spam_logs ADD CONSTRAINT spam_logs_pkey PRIMARY KEY (id); @@ -38805,8 +38785,6 @@ CREATE INDEX idx_slack_integrations_scopes_on_slack_api_scope_id ON slack_integr CREATE UNIQUE INDEX idx_software_license_policies_unique_on_custom_license_project ON software_license_policies USING btree (project_id, custom_software_license_id, scan_result_policy_id); -CREATE INDEX idx_software_licenses_lower_name ON software_licenses USING btree (lower((name)::text)); - CREATE INDEX idx_status_check_responses_on_id_and_status ON status_check_responses USING btree (id, status); CREATE INDEX idx_streaming_group_namespace_filters_on_namespace_id ON audit_events_streaming_group_namespace_filters USING btree (namespace_id); @@ -43053,10 +43031,6 @@ CREATE INDEX index_software_license_policies_on_approval_policy_rule_id ON softw CREATE INDEX index_software_license_policies_on_scan_result_policy_id ON software_license_policies USING btree (scan_result_policy_id); -CREATE INDEX index_software_licenses_on_spdx_identifier ON software_licenses USING btree (spdx_identifier); - -CREATE UNIQUE INDEX index_software_licenses_on_unique_name ON software_licenses USING btree (name); - CREATE INDEX index_sop_configurations_project_id_policy_project_id ON security_orchestration_policy_configurations USING btree (security_policy_management_project_id, project_id); CREATE INDEX index_sop_schedules_on_sop_configuration_id ON security_orchestration_policy_rule_schedules USING btree (security_orchestration_policy_configuration_id); -- GitLab From e40ee4536399af7655fe706a4e60be9b1fefbc2f Mon Sep 17 00:00:00 2001 From: mc_rocha Date: Fri, 26 Sep 2025 11:16:05 -0400 Subject: [PATCH 2/5] Fix spec errors --- db/docs/software_licenses.yml | 13 ------------- .../restrict_gitlab_schema_spec.rb | 12 ++++++------ 2 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 db/docs/software_licenses.yml diff --git a/db/docs/software_licenses.yml b/db/docs/software_licenses.yml deleted file mode 100644 index c9161d7dcbd279..00000000000000 --- a/db/docs/software_licenses.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -table_name: software_licenses -classes: -- SoftwareLicense -feature_categories: -- security_policy_management -description: Normalized software licenses to use in conjunction with License Compliance - features (like software license policies) -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6246 -milestone: '11.2' -gitlab_schema: gitlab_main_org -table_size: small -sharding_key_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/497969 diff --git a/spec/lib/gitlab/database/migration_helpers/restrict_gitlab_schema_spec.rb b/spec/lib/gitlab/database/migration_helpers/restrict_gitlab_schema_spec.rb index 2e4611e3f6aa92..89778ef8acc16d 100644 --- a/spec/lib/gitlab/database/migration_helpers/restrict_gitlab_schema_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers/restrict_gitlab_schema_spec.rb @@ -235,23 +235,23 @@ def down } } }, - "does insert into software_licenses" => { + "does insert into features" => { migration: ->(klass) do def up - software_license_class.create!(name: 'aaa') + features_class.create!(key: 'aaa') end def down - software_license_class.where(name: 'aaa').delete_all + features_class.where(key: 'aaa').delete_all end - def software_license_class + def features_class Class.new(Gitlab::Database::Migration[2.0]::MigrationRecord) do - self.table_name = 'software_licenses' + self.table_name = 'features' end end end, - query_matcher: /INSERT INTO "software_licenses"/, + query_matcher: /INSERT INTO "features"/, expected: { no_gitlab_schema: { main: :dml_not_allowed, -- GitLab From a1e1758c67a387ca99428df8a286c554d91a19ea Mon Sep 17 00:00:00 2001 From: mc_rocha Date: Mon, 29 Sep 2025 17:24:23 -0400 Subject: [PATCH 3/5] Cleanup BBM related to software_licenses table --- ...ueue_backfill_software_license_policies.rb | 16 +- ...ackfill_licenses_outside_spdx_catalogue.rb | 15 +- ...ackfill_licenses_outside_spdx_catalogue.rb | 17 ++ ...anup_backfill_software_license_policies.rb | 17 ++ db/schema_migrations/20250929205208 | 1 + db/schema_migrations/20250929210334 | 1 + ...ackfill_licenses_outside_spdx_catalogue.rb | 54 ------ .../backfill_software_license_policies.rb | 72 -------- ...ll_licenses_outside_spdx_catalogue_spec.rb | 155 ------------------ ...backfill_software_license_policies_spec.rb | 140 ---------------- ...ackfill_licenses_outside_spdx_catalogue.rb | 13 -- .../backfill_software_license_policies.rb | 13 -- ...backfill_software_license_policies_spec.rb | 27 --- ...ll_licenses_outside_spdx_catalogue_spec.rb | 26 --- 14 files changed, 42 insertions(+), 525 deletions(-) create mode 100644 db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb create mode 100644 db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb create mode 100644 db/schema_migrations/20250929205208 create mode 100644 db/schema_migrations/20250929210334 delete mode 100644 ee/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb delete mode 100644 ee/lib/ee/gitlab/background_migration/backfill_software_license_policies.rb delete mode 100644 ee/spec/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue_spec.rb delete mode 100644 ee/spec/lib/ee/gitlab/background_migration/backfill_software_license_policies_spec.rb delete mode 100644 lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb delete mode 100644 lib/gitlab/background_migration/backfill_software_license_policies.rb delete mode 100644 spec/migrations/20250214214518_queue_backfill_software_license_policies_spec.rb delete mode 100644 spec/migrations/20250505171359_queue_backfill_licenses_outside_spdx_catalogue_spec.rb diff --git a/db/post_migrate/20250214214518_queue_backfill_software_license_policies.rb b/db/post_migrate/20250214214518_queue_backfill_software_license_policies.rb index e73f1df78bdf40..b9945f7cb7bb9e 100644 --- a/db/post_migrate/20250214214518_queue_backfill_software_license_policies.rb +++ b/db/post_migrate/20250214214518_queue_backfill_software_license_policies.rb @@ -10,18 +10,8 @@ class QueueBackfillSoftwareLicensePolicies < Gitlab::Database::Migration[2.2] BATCH_SIZE = 1000 SUB_BATCH_SIZE = 100 - def up - queue_batched_background_migration( - MIGRATION, - :software_license_policies, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + # This migration is already finalized and we are removing the software_licenses table. + def up; end - def down - delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) - end + def down; end end diff --git a/db/post_migrate/20250505171359_queue_backfill_licenses_outside_spdx_catalogue.rb b/db/post_migrate/20250505171359_queue_backfill_licenses_outside_spdx_catalogue.rb index 97f2ca342fbf82..8cc2345f6e2cd5 100644 --- a/db/post_migrate/20250505171359_queue_backfill_licenses_outside_spdx_catalogue.rb +++ b/db/post_migrate/20250505171359_queue_backfill_licenses_outside_spdx_catalogue.rb @@ -9,17 +9,8 @@ class QueueBackfillLicensesOutsideSpdxCatalogue < Gitlab::Database::Migration[2. BATCH_SIZE = 1000 SUB_BATCH_SIZE = 100 - def up - queue_batched_background_migration( - MIGRATION, - :software_license_policies, - :id, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end + # This migration is already finalized and we are removing the software_licenses table. + def up; end - def down - delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) - end + def down; end end diff --git a/db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb b/db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb new file mode 100644 index 00000000000000..bc8e116156faff --- /dev/null +++ b/db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CleanupBackfillLicensesOutsideSpdxCatalogue < Gitlab::Database::Migration[2.3] + MIGRATION = "BackfillLicensesOutsideSpdxCatalogue" + + restrict_gitlab_migration gitlab_schema: :gitlab_main_org + milestone '18.5' + + def up + delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) + end + + def down; end +end diff --git a/db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb b/db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb new file mode 100644 index 00000000000000..f559f8f37976c4 --- /dev/null +++ b/db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CleanupBackfillSoftwareLicensePolicies < Gitlab::Database::Migration[2.3] + MIGRATION = "BackfillSoftwareLicensePolicies" + + restrict_gitlab_migration gitlab_schema: :gitlab_main_org + milestone '18.5' + + def up + delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) + end + + def down; end +end diff --git a/db/schema_migrations/20250929205208 b/db/schema_migrations/20250929205208 new file mode 100644 index 00000000000000..13b6753fd24bd7 --- /dev/null +++ b/db/schema_migrations/20250929205208 @@ -0,0 +1 @@ +65565f38bb05774bfa3ef79563cf097a5a6f4b2a21409fd84b5a452fcee05617 \ No newline at end of file diff --git a/db/schema_migrations/20250929210334 b/db/schema_migrations/20250929210334 new file mode 100644 index 00000000000000..577c5c0199e70f --- /dev/null +++ b/db/schema_migrations/20250929210334 @@ -0,0 +1 @@ +a184ee6b7ba5b1849f13016d680b35ea96d39016532ff250f02356766ca88257 \ No newline at end of file diff --git a/ee/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb b/ee/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb deleted file mode 100644 index fde37965e35ce2..00000000000000 --- a/ee/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -module EE - module Gitlab - module BackgroundMigration - module BackfillLicensesOutsideSpdxCatalogue - extend ActiveSupport::Concern - extend ::Gitlab::Utils::Override - - prepended do - operation_name :backfill_licenses_outside_spdx_catalogue - scope_to ->(relation) do - relation.where(software_license_spdx_identifier: nil, custom_software_license_id: nil) - .where.not(software_license_id: nil) - end - end - - class SoftwareLicensePolicy < ::ApplicationRecord - self.table_name = 'software_license_policies' - - belongs_to :software_license, -> { readonly } - end - - class SoftwareLicense < ::ApplicationRecord - self.table_name = 'software_licenses' - end - - class CustomSoftwareLicense < ::ApplicationRecord - self.table_name = 'custom_software_licenses' - end - - override :perform - def perform - each_sub_batch do |sub_batch| - SoftwareLicensePolicy.id_in(sub_batch).includes(:software_license).find_each do |software_license_policy| - software_license_name = software_license_policy.software_license.name - - custom_software_license = find_or_create_custom_software_license(software_license_name, - software_license_policy.project_id) - - software_license_policy.update!(custom_software_license_id: custom_software_license.id) - end - end - end - - def find_or_create_custom_software_license(name, project_id) - params = { name: name, project_id: project_id } - CustomSoftwareLicense.upsert(params, unique_by: [:project_id, :name]) - CustomSoftwareLicense.find_by(params) - end - end - end - end -end diff --git a/ee/lib/ee/gitlab/background_migration/backfill_software_license_policies.rb b/ee/lib/ee/gitlab/background_migration/backfill_software_license_policies.rb deleted file mode 100644 index d2b5a018240577..00000000000000 --- a/ee/lib/ee/gitlab/background_migration/backfill_software_license_policies.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -module EE - module Gitlab - module BackgroundMigration - module BackfillSoftwareLicensePolicies - extend ActiveSupport::Concern - extend ::Gitlab::Utils::Override - include ::Gitlab::Utils::StrongMemoize - - prepended do - operation_name :migrate_licenses_outside_spdx_to_custom_license - scope_to ->(relation) do - relation.where(software_license_spdx_identifier: nil) - .where(custom_software_license_id: nil) - .where.not(software_license_id: nil) - end - end - - class SoftwareLicensePolicy < ::ApplicationRecord - self.table_name = 'software_license_policies' - - belongs_to :software_license, -> { readonly } - end - - class SoftwareLicense < ::ApplicationRecord - self.table_name = 'software_licenses' - end - - class CustomSoftwareLicense < ::ApplicationRecord - self.table_name = 'custom_software_licenses' - end - - override :perform - def perform - each_sub_batch do |sub_batch| - SoftwareLicensePolicy.id_in(sub_batch).includes(:software_license).find_each do |software_license_policy| - software_license_name = software_license_policy.software_license.name - spdx_identifier = licenses_map[software_license_name] - - if spdx_identifier.present? - software_license_policy.update!(software_license_spdx_identifier: spdx_identifier) - else - custom_software_license = find_or_create_custom_software_license(software_license_name, - software_license_policy.project_id) - - software_license_policy.update!(custom_software_license_id: custom_software_license.id) - end - end - end - end - - private - - def find_or_create_custom_software_license(name, project_id) - params = { name: name, project_id: project_id } - CustomSoftwareLicense.upsert(params, unique_by: [:project_id, :name]) - CustomSoftwareLicense.find_by(params) - end - - def licenses_map - catalog_licenses = ::Gitlab::SPDX::Catalogue.latest_active_licenses - - catalog_licenses.each_with_object({}) do |license, map| - map[license.name] = license.id - end - end - strong_memoize_attr :licenses_map - end - end - end -end diff --git a/ee/spec/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue_spec.rb b/ee/spec/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue_spec.rb deleted file mode 100644 index af031fd71bd7c1..00000000000000 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::BackgroundMigration::BackfillLicensesOutsideSpdxCatalogue, - feature_category: :security_policy_management, - schema: 20250505171359 do - let(:organizations) { table(:organizations) } - let(:namespaces) { table(:namespaces) } - let(:projects) { table(:projects) } - - let(:software_licenses) { table(:software_licenses) } - let(:custom_software_licenses) { table(:custom_software_licenses) } - let(:software_license_policies) { table(:software_license_policies) } - - let!(:organization) { organizations.create!(name: 'organization', path: 'organization') } - let!(:namespace) { namespaces.create!(name: 'namespace', path: 'namespace', organization_id: organization.id) } - let!(:project) do - projects.create!(namespace_id: namespace.id, project_namespace_id: namespace.id, organization_id: organization.id) - end - - subject(:perform_migration) do - described_class.new( - start_id: software_license_policies.minimum(:id), - end_id: software_license_policies.maximum(:id), - batch_table: :software_license_policies, - batch_column: :id, - sub_batch_size: 100, - pause_ms: 2.minutes, - connection: ApplicationRecord.connection - ).perform - end - - shared_examples 'does not create a new custom software license' do - it 'does not create a new custom software license' do - expect { perform_migration }.not_to change { custom_software_licenses.count } - end - end - - shared_examples 'creates a new custom software license' do - it 'creates a new custom software license' do - expect { perform_migration }.to change { custom_software_licenses.count }.by(1) - end - end - - shared_examples_for 'when the software license policy has the custom_software_license_id set' do - it_behaves_like 'does not create a new custom software license' - - it 'does not change the custom_software_license_id' do - expect { perform_migration }.not_to change { software_license_policy.reload.custom_software_license_id } - end - end - - context 'when the software license policy has the software_license_spdx_identifier set' do - let(:software_license_spdx_identifier) { 'MIT' } - let!(:mit_license) do - software_licenses.create!(name: 'MIT License', spdx_identifier: software_license_spdx_identifier) - end - - let!(:software_license_policy) do - software_license_policies.create!(project_id: project.id, software_license_id: mit_license.id, - software_license_spdx_identifier: software_license_spdx_identifier) - end - - it 'does not backfill the custom_software_license_id' do - expect(software_license_policy.custom_software_license_id).to be_nil - - perform_migration - - software_license_policy.reload - - expect(software_license_policy.custom_software_license_id).to be_nil - end - end - - context 'when the software license policy has the custom_software_license_id set' do - let(:custom_license_name) { 'Custom License' } - let!(:custom_software_license) do - custom_software_licenses.create!(name: custom_license_name, project_id: project.id) - end - - let(:custom_software_license_id) { custom_software_license.id } - - let!(:software_license_policy) do - software_license_policies.create!(project_id: project.id, - custom_software_license_id: custom_software_license_id) - end - - it_behaves_like 'when the software license policy has the custom_software_license_id set' - end - - context 'when the software license policy does not have the software_license_spdx_identifier set' do - let(:software_license_outside_spdx_name) { 'Software License Outside SPDX' } - let!(:software_license_outside_spdx) do - software_licenses.create!(name: 'Software License Outside SPDX', spdx_identifier: nil) - end - - let!(:software_license_policy) do - software_license_policies.create!(project_id: project.id, - software_license_id: software_license_outside_spdx.id, software_license_spdx_identifier: nil, - custom_software_license_id: custom_software_license_id) - end - - context 'when the software license policy has the custom_software_license_id set' do - let!(:custom_software_license) do - custom_software_licenses.create!(name: software_license_outside_spdx_name, project_id: project.id) - end - - let!(:custom_software_license_id) { custom_software_license.id } - - it_behaves_like 'when the software license policy has the custom_software_license_id set' - end - - context 'when the software license policy does not have the custom_software_license_id set' do - let(:custom_software_license_id) { nil } - - context 'when the custom_software_licenses table does not contain an entry with the same name and project_id' do - it_behaves_like 'creates a new custom software license' - - it 'backfill the custom_software_license_id' do - expect(software_license_policy.software_license_id).to eq(software_license_outside_spdx.id) - expect(software_license_policy.custom_software_license_id).to be_nil - - perform_migration - - software_license_policy.reload - custom_software_license = custom_software_licenses.last - - expect(software_license_policy.software_license_id).to eq(software_license_outside_spdx.id) - expect(software_license_policy.custom_software_license_id).to eq(custom_software_license.id) - end - end - - context 'when the custom_software_licenses table contains an entry with the same name and project_id' do - let!(:existing_custom_software_license) do - custom_software_licenses.create!(name: software_license_outside_spdx_name, project_id: project.id) - end - - it_behaves_like 'does not create a new custom software license' - - it 'backfill the custom_software_license_id with the existing custom_software_license' do - expect(software_license_policy.software_license_id).to eq(software_license_outside_spdx.id) - expect(software_license_policy.custom_software_license_id).to be_nil - - perform_migration - - software_license_policy.reload - - expect(software_license_policy.software_license_id).to eq(software_license_outside_spdx.id) - expect(software_license_policy.custom_software_license_id).to eq(existing_custom_software_license.id) - end - end - end - end -end diff --git a/ee/spec/lib/ee/gitlab/background_migration/backfill_software_license_policies_spec.rb b/ee/spec/lib/ee/gitlab/background_migration/backfill_software_license_policies_spec.rb deleted file mode 100644 index eb8d92af43b2b4..00000000000000 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_software_license_policies_spec.rb +++ /dev/null @@ -1,140 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::BackgroundMigration::BackfillSoftwareLicensePolicies, feature_category: :security_policy_management do - let(:software_licenses) { table(:software_licenses) } - let(:custom_software_licenses) { table(:custom_software_licenses) } - let(:software_license_policies) { table(:software_license_policies) } - let(:organizations) { table(:organizations) } - let(:projects) { table(:projects) } - let(:namespaces) { table(:namespaces) } - - let!(:organization) { organizations.create!(name: 'organization', path: 'organization') } - let!(:namespace) { namespaces.create!(name: 'namespace', path: 'namespace', organization_id: organization.id) } - let!(:software_license) { software_licenses.create!(name: 'MIT License', spdx_identifier: 'MIT') } - let(:software_license_id) { software_license.id } - let(:software_license_spdx_identifier) { nil } - let(:custom_software_license_id) { nil } - let!(:project) do - projects.create!(namespace_id: namespace.id, project_namespace_id: namespace.id, organization_id: organization.id) - end - - let!(:software_license_policy) do - software_license_policies.create!(project_id: project.id, - software_license_id: software_license_id, - software_license_spdx_identifier: software_license_spdx_identifier, - custom_software_license_id: custom_software_license_id) - end - - subject(:perform_migration) do - described_class.new( - start_id: software_license_policies.minimum(:id), - end_id: software_license_policies.maximum(:id), - batch_table: :software_license_policies, - batch_column: :id, - sub_batch_size: 100, - pause_ms: 2.minutes, - connection: ApplicationRecord.connection - ).perform - end - - shared_examples 'does not create custom software licenses records' do - it 'does not creates custom software licenses records' do - expect { perform_migration }.not_to change { custom_software_licenses.count } - end - end - - shared_examples 'creates a new custom software license' do - it 'creates a new custom software license' do - expect { perform_migration }.to change { custom_software_licenses.count }.by(1) - end - end - - context 'when there are software_license_policies with software_license_spdx_identifier' do - let(:software_license_spdx_identifier) { 'MIT' } - - it_behaves_like 'does not create custom software licenses records' - end - - context 'when there are software_license_policies with custom_software_license_id' do - let!(:custom_software_license) { custom_software_licenses.create!(name: 'Custom License', project_id: project.id) } - let(:software_license_id) { nil } - let(:custom_software_license_id) { custom_software_license.id } - - it_behaves_like 'does not create custom software licenses records' - end - - context <<~DESCRIPTION do - when there are software_license_policies - without software_license_spdx_identifier - and without custom_software_license_id - DESCRIPTION - context 'when the software license is in the SPDX catalog' do - it_behaves_like 'does not create custom software licenses records' - - it 'sets the software_license_spdx_identifier' do - expect { perform_migration }.to change { - software_license_policy.reload.software_license_spdx_identifier - }.from(nil).to('MIT') - end - end - - context 'when the software license is not in the SPDX catalog' do - let!(:software_license) { software_licenses.create!(name: 'Custom License') } - - shared_examples_for 'sets the custom_software_license_id' do - it 'sets the custom_software_license_id' do - expect(software_license_policy.custom_software_license_id).to be_nil - - perform_migration - - custom_software_license = custom_software_licenses.last - - expect(software_license_policy.reload.custom_software_license_id).to eq(custom_software_license.id) - end - end - - context 'when a custom_software_license with the software_license name does not exist' do - it 'does not sets the software_license_spdx_identifier' do - expect { perform_migration }.not_to change { - software_license_policy.reload.software_license_spdx_identifier - }.from(nil) - end - - it_behaves_like 'creates a new custom software license' - it_behaves_like 'sets the custom_software_license_id' - end - - context 'when a custom_software_license with the software_license name exist' do - let!(:custom_software_license) do - custom_software_licenses.create!(name: 'Custom License', project_id: project_id) - end - - context 'when the custom_software_license is associated to another project' do - let!(:other_organization) { organizations.create!(name: 'other organization', path: 'other organization') } - let!(:other_namespace) do - namespaces.create!(name: 'other namespace', path: 'other namespace', organization_id: organization.id) - end - - let!(:other_project) do - projects.create!(namespace_id: other_namespace.id, project_namespace_id: other_namespace.id, - organization_id: other_organization.id) - end - - let(:project_id) { other_project.id } - - it_behaves_like 'creates a new custom software license' - it_behaves_like 'sets the custom_software_license_id' - end - - context 'when the custom_software_license is associated to the same project' do - let(:project_id) { project.id } - - it_behaves_like 'does not create custom software licenses records' - it_behaves_like 'sets the custom_software_license_id' - end - end - end - end -end diff --git a/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb b/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb deleted file mode 100644 index 94c3a32f5b75fc..00000000000000 --- a/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module BackgroundMigration - class BackfillLicensesOutsideSpdxCatalogue < BatchedMigrationJob - feature_category :security_policy_management - - def perform; end - end - end -end - -Gitlab::BackgroundMigration::BackfillLicensesOutsideSpdxCatalogue.prepend_mod diff --git a/lib/gitlab/background_migration/backfill_software_license_policies.rb b/lib/gitlab/background_migration/backfill_software_license_policies.rb deleted file mode 100644 index 7fbd1e12860faf..00000000000000 --- a/lib/gitlab/background_migration/backfill_software_license_policies.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module BackgroundMigration - class BackfillSoftwareLicensePolicies < BatchedMigrationJob - feature_category :security_policy_management - - def perform; end - end - end -end - -Gitlab::BackgroundMigration::BackfillSoftwareLicensePolicies.prepend_mod diff --git a/spec/migrations/20250214214518_queue_backfill_software_license_policies_spec.rb b/spec/migrations/20250214214518_queue_backfill_software_license_policies_spec.rb deleted file mode 100644 index 2cbe813d6f9f81..00000000000000 --- a/spec/migrations/20250214214518_queue_backfill_software_license_policies_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require_migration! - -RSpec.describe QueueBackfillSoftwareLicensePolicies, migration: :gitlab_main_org, feature_category: :security_policy_management do - let!(:batched_migration) { described_class::MIGRATION } - - it 'schedules a new batched migration' do - reversible_migration do |migration| - migration.before -> { - expect(batched_migration).not_to have_scheduled_batched_migration - } - - migration.after -> { - expect(batched_migration).to have_scheduled_batched_migration( - gitlab_schema: :gitlab_main, - table_name: :software_license_policies, - column_name: :id, - interval: described_class::DELAY_INTERVAL, - batch_size: described_class::BATCH_SIZE, - sub_batch_size: described_class::SUB_BATCH_SIZE - ) - } - end - end -end diff --git a/spec/migrations/20250505171359_queue_backfill_licenses_outside_spdx_catalogue_spec.rb b/spec/migrations/20250505171359_queue_backfill_licenses_outside_spdx_catalogue_spec.rb deleted file mode 100644 index 1dc8dca82588e0..00000000000000 --- a/spec/migrations/20250505171359_queue_backfill_licenses_outside_spdx_catalogue_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require_migration! - -RSpec.describe QueueBackfillLicensesOutsideSpdxCatalogue, migration: :gitlab_main_org, feature_category: :security_policy_management do - let!(:batched_migration) { described_class::MIGRATION } - - it 'schedules a new batched migration' do - reversible_migration do |migration| - migration.before -> { - expect(batched_migration).not_to have_scheduled_batched_migration - } - - migration.after -> { - expect(batched_migration).to have_scheduled_batched_migration( - gitlab_schema: :gitlab_main, - table_name: :software_license_policies, - column_name: :id, - batch_size: described_class::BATCH_SIZE, - sub_batch_size: described_class::SUB_BATCH_SIZE - ) - } - end - end -end -- GitLab From 495b430eae9281b1fcc740426477c796df5ad5f6 Mon Sep 17 00:00:00 2001 From: mc_rocha Date: Fri, 17 Oct 2025 12:04:14 -0400 Subject: [PATCH 4/5] Update milestone and migrations timestamps --- db/docs/deleted_tables/software_licenses.yml | 2 +- ...es.rb => 20251017155822_drop_software_licenses.rb} | 2 +- ...eanup_backfill_licenses_outside_spdx_catalogue.rb} | 5 +---- ...829_cleanup_backfill_software_license_policies.rb} | 5 +---- db/schema_migrations/20250923165400 | 1 - db/schema_migrations/20250929205208 | 1 - db/schema_migrations/20250929210334 | 1 - db/schema_migrations/20251017155822 | 1 + db/schema_migrations/20251017155824 | 1 + db/schema_migrations/20251017155829 | 1 + .../backfill_licenses_outside_spdx_catalogue.rb | 11 +++++++++++ .../backfill_software_license_policies.rb | 11 +++++++++++ 12 files changed, 29 insertions(+), 13 deletions(-) rename db/post_migrate/{20250923165400_drop_software_licenses.rb => 20251017155822_drop_software_licenses.rb} (97%) rename db/post_migrate/{20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb => 20251017155824_cleanup_backfill_licenses_outside_spdx_catalogue.rb} (69%) rename db/post_migrate/{20250929210334_cleanup_backfill_software_license_policies.rb => 20251017155829_cleanup_backfill_software_license_policies.rb} (69%) delete mode 100644 db/schema_migrations/20250923165400 delete mode 100644 db/schema_migrations/20250929205208 delete mode 100644 db/schema_migrations/20250929210334 create mode 100644 db/schema_migrations/20251017155822 create mode 100644 db/schema_migrations/20251017155824 create mode 100644 db/schema_migrations/20251017155829 create mode 100644 lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb create mode 100644 lib/gitlab/background_migration/backfill_software_license_policies.rb diff --git a/db/docs/deleted_tables/software_licenses.yml b/db/docs/deleted_tables/software_licenses.yml index f8cf88c3694653..b68010adb9ebdd 100644 --- a/db/docs/deleted_tables/software_licenses.yml +++ b/db/docs/deleted_tables/software_licenses.yml @@ -11,4 +11,4 @@ milestone: '11.2' gitlab_schema: gitlab_main_org table_size: small removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/206085 -removed_in_milestone: '18.5' +removed_in_milestone: '18.6' diff --git a/db/post_migrate/20250923165400_drop_software_licenses.rb b/db/post_migrate/20251017155822_drop_software_licenses.rb similarity index 97% rename from db/post_migrate/20250923165400_drop_software_licenses.rb rename to db/post_migrate/20251017155822_drop_software_licenses.rb index a40a63b4e2972d..2d22eeff18babd 100644 --- a/db/post_migrate/20250923165400_drop_software_licenses.rb +++ b/db/post_migrate/20251017155822_drop_software_licenses.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class DropSoftwareLicenses < Gitlab::Database::Migration[2.3] - milestone '18.5' + milestone '18.6' disable_ddl_transaction! def up diff --git a/db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb b/db/post_migrate/20251017155824_cleanup_backfill_licenses_outside_spdx_catalogue.rb similarity index 69% rename from db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb rename to db/post_migrate/20251017155824_cleanup_backfill_licenses_outside_spdx_catalogue.rb index bc8e116156faff..994cf43f6c1a2e 100644 --- a/db/post_migrate/20250929205208_cleanup_backfill_licenses_outside_spdx_catalogue.rb +++ b/db/post_migrate/20251017155824_cleanup_backfill_licenses_outside_spdx_catalogue.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class CleanupBackfillLicensesOutsideSpdxCatalogue < Gitlab::Database::Migration[2.3] MIGRATION = "BackfillLicensesOutsideSpdxCatalogue" restrict_gitlab_migration gitlab_schema: :gitlab_main_org - milestone '18.5' + milestone '18.6' def up delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) diff --git a/db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb b/db/post_migrate/20251017155829_cleanup_backfill_software_license_policies.rb similarity index 69% rename from db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb rename to db/post_migrate/20251017155829_cleanup_backfill_software_license_policies.rb index f559f8f37976c4..b2b1c9848e6657 100644 --- a/db/post_migrate/20250929210334_cleanup_backfill_software_license_policies.rb +++ b/db/post_migrate/20251017155829_cleanup_backfill_software_license_policies.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class CleanupBackfillSoftwareLicensePolicies < Gitlab::Database::Migration[2.3] MIGRATION = "BackfillSoftwareLicensePolicies" restrict_gitlab_migration gitlab_schema: :gitlab_main_org - milestone '18.5' + milestone '18.6' def up delete_batched_background_migration(MIGRATION, :software_license_policies, :id, []) diff --git a/db/schema_migrations/20250923165400 b/db/schema_migrations/20250923165400 deleted file mode 100644 index 01bd3b48121905..00000000000000 --- a/db/schema_migrations/20250923165400 +++ /dev/null @@ -1 +0,0 @@ -b654b4d8c131891fcab94032a8b99a638cb7ab02f916ebc6ef56354348cfc02e \ No newline at end of file diff --git a/db/schema_migrations/20250929205208 b/db/schema_migrations/20250929205208 deleted file mode 100644 index 13b6753fd24bd7..00000000000000 --- a/db/schema_migrations/20250929205208 +++ /dev/null @@ -1 +0,0 @@ -65565f38bb05774bfa3ef79563cf097a5a6f4b2a21409fd84b5a452fcee05617 \ No newline at end of file diff --git a/db/schema_migrations/20250929210334 b/db/schema_migrations/20250929210334 deleted file mode 100644 index 577c5c0199e70f..00000000000000 --- a/db/schema_migrations/20250929210334 +++ /dev/null @@ -1 +0,0 @@ -a184ee6b7ba5b1849f13016d680b35ea96d39016532ff250f02356766ca88257 \ No newline at end of file diff --git a/db/schema_migrations/20251017155822 b/db/schema_migrations/20251017155822 new file mode 100644 index 00000000000000..82baa0b83e2895 --- /dev/null +++ b/db/schema_migrations/20251017155822 @@ -0,0 +1 @@ +31120909ec2c8a83794a16ebe4164ecda8affbc906c3f0ac1b23dee2a69aa1ae \ No newline at end of file diff --git a/db/schema_migrations/20251017155824 b/db/schema_migrations/20251017155824 new file mode 100644 index 00000000000000..7ba114c74d2770 --- /dev/null +++ b/db/schema_migrations/20251017155824 @@ -0,0 +1 @@ +311eca4052b9b92855489272ce343e5603ed2ca00c49c85657b3575052e7f9e5 \ No newline at end of file diff --git a/db/schema_migrations/20251017155829 b/db/schema_migrations/20251017155829 new file mode 100644 index 00000000000000..e642851760f371 --- /dev/null +++ b/db/schema_migrations/20251017155829 @@ -0,0 +1 @@ +7fbb82d82c60c53ff18dceb04c9caa0a21a23b761b6073a90b071bcd4304bd36 \ No newline at end of file diff --git a/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb b/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb new file mode 100644 index 00000000000000..a2736264ab2513 --- /dev/null +++ b/lib/gitlab/background_migration/backfill_licenses_outside_spdx_catalogue.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + class BackfillLicensesOutsideSpdxCatalogue < BatchedMigrationJob + feature_category :security_policy_management + + def perform; end + end + end +end diff --git a/lib/gitlab/background_migration/backfill_software_license_policies.rb b/lib/gitlab/background_migration/backfill_software_license_policies.rb new file mode 100644 index 00000000000000..7c6973af4818d2 --- /dev/null +++ b/lib/gitlab/background_migration/backfill_software_license_policies.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + class BackfillSoftwareLicensePolicies < BatchedMigrationJob + feature_category :security_policy_management + + def perform; end + end + end +end -- GitLab From 85b0acbc2255c623c639f7f32f03fa72c95996e7 Mon Sep 17 00:00:00 2001 From: mc_rocha Date: Wed, 5 Nov 2025 17:13:55 -0500 Subject: [PATCH 5/5] Remove migration to drop software_licenses table --- .../software_licenses.yml | 9 +++---- .../20251017155822_drop_software_licenses.rb | 21 --------------- db/schema_migrations/20251017155822 | 1 - db/structure.sql | 26 +++++++++++++++++++ 4 files changed, 30 insertions(+), 27 deletions(-) rename db/docs/{deleted_tables => }/software_licenses.yml (51%) delete mode 100644 db/post_migrate/20251017155822_drop_software_licenses.rb delete mode 100644 db/schema_migrations/20251017155822 diff --git a/db/docs/deleted_tables/software_licenses.yml b/db/docs/software_licenses.yml similarity index 51% rename from db/docs/deleted_tables/software_licenses.yml rename to db/docs/software_licenses.yml index b68010adb9ebdd..c9161d7dcbd279 100644 --- a/db/docs/deleted_tables/software_licenses.yml +++ b/db/docs/software_licenses.yml @@ -1,14 +1,13 @@ --- table_name: software_licenses classes: - - SoftwareLicense +- SoftwareLicense feature_categories: - - security_policy_management +- security_policy_management description: Normalized software licenses to use in conjunction with License Compliance - features (like software license policies). Scheduled for removal in https://gitlab.com/gitlab-org/gitlab/-/issues/497969 + features (like software license policies) introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6246 milestone: '11.2' gitlab_schema: gitlab_main_org table_size: small -removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/206085 -removed_in_milestone: '18.6' +sharding_key_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/497969 diff --git a/db/post_migrate/20251017155822_drop_software_licenses.rb b/db/post_migrate/20251017155822_drop_software_licenses.rb deleted file mode 100644 index 2d22eeff18babd..00000000000000 --- a/db/post_migrate/20251017155822_drop_software_licenses.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class DropSoftwareLicenses < Gitlab::Database::Migration[2.3] - milestone '18.6' - disable_ddl_transaction! - - def up - drop_table :software_licenses - end - - def down - create_table :software_licenses do |t| - t.string :name, null: false - t.string :spdx_identifier, null: true, limit: 255 - end - - add_concurrent_index :software_licenses, 'LOWER(name)', name: 'idx_software_licenses_lower_name' - add_concurrent_index :software_licenses, :spdx_identifier, name: 'index_software_licenses_on_spdx_identifier' - add_concurrent_index :software_licenses, :name, unique: true, name: 'index_software_licenses_on_unique_name' - end -end diff --git a/db/schema_migrations/20251017155822 b/db/schema_migrations/20251017155822 deleted file mode 100644 index 82baa0b83e2895..00000000000000 --- a/db/schema_migrations/20251017155822 +++ /dev/null @@ -1 +0,0 @@ -31120909ec2c8a83794a16ebe4164ecda8affbc906c3f0ac1b23dee2a69aa1ae \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 64699250c5b77d..cfade9c0c09b1b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -26723,6 +26723,21 @@ CREATE SEQUENCE software_license_policies_id_seq ALTER SEQUENCE software_license_policies_id_seq OWNED BY software_license_policies.id; +CREATE TABLE software_licenses ( + id bigint NOT NULL, + name character varying NOT NULL, + spdx_identifier character varying(255) +); + +CREATE SEQUENCE software_licenses_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE software_licenses_id_seq OWNED BY software_licenses.id; + CREATE TABLE spam_logs ( id bigint NOT NULL, user_id bigint, @@ -32046,6 +32061,8 @@ ALTER TABLE ONLY snippets ALTER COLUMN id SET DEFAULT nextval('snippets_id_seq': ALTER TABLE ONLY software_license_policies ALTER COLUMN id SET DEFAULT nextval('software_license_policies_id_seq'::regclass); +ALTER TABLE ONLY software_licenses ALTER COLUMN id SET DEFAULT nextval('software_licenses_id_seq'::regclass); + ALTER TABLE ONLY spam_logs ALTER COLUMN id SET DEFAULT nextval('spam_logs_id_seq'::regclass); ALTER TABLE ONLY sprints ALTER COLUMN id SET DEFAULT nextval('sprints_id_seq'::regclass); @@ -35661,6 +35678,9 @@ ALTER TABLE ONLY snippets ALTER TABLE ONLY software_license_policies ADD CONSTRAINT software_license_policies_pkey PRIMARY KEY (id); +ALTER TABLE ONLY software_licenses + ADD CONSTRAINT software_licenses_pkey PRIMARY KEY (id); + ALTER TABLE ONLY spam_logs ADD CONSTRAINT spam_logs_pkey PRIMARY KEY (id); @@ -38785,6 +38805,8 @@ CREATE INDEX idx_slack_integrations_scopes_on_slack_api_scope_id ON slack_integr CREATE UNIQUE INDEX idx_software_license_policies_unique_on_custom_license_project ON software_license_policies USING btree (project_id, custom_software_license_id, scan_result_policy_id); +CREATE INDEX idx_software_licenses_lower_name ON software_licenses USING btree (lower((name)::text)); + CREATE INDEX idx_status_check_responses_on_id_and_status ON status_check_responses USING btree (id, status); CREATE INDEX idx_streaming_group_namespace_filters_on_namespace_id ON audit_events_streaming_group_namespace_filters USING btree (namespace_id); @@ -43031,6 +43053,10 @@ CREATE INDEX index_software_license_policies_on_approval_policy_rule_id ON softw CREATE INDEX index_software_license_policies_on_scan_result_policy_id ON software_license_policies USING btree (scan_result_policy_id); +CREATE INDEX index_software_licenses_on_spdx_identifier ON software_licenses USING btree (spdx_identifier); + +CREATE UNIQUE INDEX index_software_licenses_on_unique_name ON software_licenses USING btree (name); + CREATE INDEX index_sop_configurations_project_id_policy_project_id ON security_orchestration_policy_configurations USING btree (security_policy_management_project_id, project_id); CREATE INDEX index_sop_schedules_on_sop_configuration_id ON security_orchestration_policy_rule_schedules USING btree (security_orchestration_policy_configuration_id); -- GitLab