diff options
Diffstat (limited to 'db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb')
-rw-r--r-- | db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb b/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb new file mode 100644 index 00000000000..d0a72ff2c43 --- /dev/null +++ b/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb @@ -0,0 +1,16 @@ +# 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 |