gitlab-org--gitlab-foss/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
480 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class CopyAdoptionSnapshotNamespace < ActiveRecord::Migration[6.0]
def up
execute <<-SQL
UPDATE analytics_devops_adoption_snapshots snapshots
SET namespace_id = segments.namespace_id
FROM analytics_devops_adoption_segments segments
WHERE snapshots.namespace_id IS NULL AND segments.id = snapshots.segment_id
SQL
end
def down
execute 'UPDATE analytics_devops_adoption_snapshots SET namespace_id = NULL'
end
end