Commit 82bc7b93 authored by Andy Soiron's avatar Andy Soiron Committed by Mayra Cabrera

Remove GitlabIssueTrackerService records

The GitlabIssueTrackerService class is not used anymore
and will be removed too.
parent d868d313
---
title: Clean up GitlabIssueTrackerService database records
merge_request: 35221
author:
type: other
# frozen_string_literal: true
class RemoveGitlabIssueTrackerServiceRecords < ActiveRecord::Migration[6.0]
DOWNTIME = false
BATCH_SIZE = 5000
disable_ddl_transaction!
class Service < ActiveRecord::Base
include EachBatch
self.table_name = 'services'
def self.gitlab_issue_tracker_service
where(type: 'GitlabIssueTrackerService')
end
end
def up
Service.each_batch(of: BATCH_SIZE) do |services|
services.gitlab_issue_tracker_service.delete_all
end
end
def down
# no-op
end
end
......@@ -23535,6 +23535,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200623000320
20200623121135
20200623141544
20200623142159
20200623170000
20200623185440
20200624075411
......
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200623142159_remove_gitlab_issue_tracker_service_records.rb')
RSpec.describe RemoveGitlabIssueTrackerServiceRecords do
let(:services) { table(:services) }
before do
5.times { services.create!(type: 'GitlabIssueTrackerService') }
services.create!(type: 'SomeOtherType')
end
it 'removes services records of type GitlabIssueTrackerService', :aggregate_failures do
expect { migrate! }.to change { services.count }.from(6).to(1)
expect(services.first.type).to eq('SomeOtherType')
expect(services.where(type: 'GitlabIssueTrackerService')).to be_empty
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment