Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230313185145_cleanup_orphan_software_licenses.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af971f692d6b6e22326c6d4492dfebf013d9f93f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

class CleanupOrphanSoftwareLicenses < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  class SoftwareLicense < MigrationRecord
    self.table_name = 'software_licenses'
  end

  class SoftwareLicensePolicy < MigrationRecord
    self.table_name = 'software_license_policies'
  end

  def up
    SoftwareLicense
      .where(spdx_identifier: nil)
      .where.not(
        id: SoftwareLicensePolicy.select(:software_license_id)
      ).delete_all
  end

  def down
    # NO-OP
  end
end