diff options
| author | Felipe Artur <felipefac@gmail.com> | 2019-05-02 16:48:02 -0300 |
|---|---|---|
| committer | Felipe Artur <felipefac@gmail.com> | 2019-05-06 15:01:53 -0300 |
| commit | 7e255f6793b8ff86777ccba087c9a76872a3819c (patch) | |
| tree | 6573083d4b42e6167ca1f1222dab430ed7d19664 /db/migrate | |
| parent | f98758753a73841d2374aad986ae795da828ddca (diff) | |
| download | gitlab-ce-issue_57906_fix_github_import.tar.gz | |
Fix issuables state_id nil when importing projects from GitHubissue_57906_fix_github_import
Issues and merge requests imported from GitHub are having state_id
set to null. This fixes the GitHub project importer and schedule
migrations to fix state_id.
Diffstat (limited to 'db/migrate')
| -rw-r--r-- | db/migrate/20190506135337_add_temporary_indexes_to_state_id.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/db/migrate/20190506135337_add_temporary_indexes_to_state_id.rb b/db/migrate/20190506135337_add_temporary_indexes_to_state_id.rb new file mode 100644 index 00000000000..8e9838e1afb --- /dev/null +++ b/db/migrate/20190506135337_add_temporary_indexes_to_state_id.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# This migration adds temporary indexes to state_id column of issues +# and merge_requests tables. It will be used only to peform the scheduling +# for populating state_id in a post migrate and will be removed after it. +# Check: ScheduleSyncIssuablesStateIdWhereNil. + +class AddTemporaryIndexesToStateId < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + %w(issues merge_requests).each do |table| + add_concurrent_index( + table, + 'id', + name: index_name_for(table), + where: "state_id IS NULL" + ) + end + end + + def down + remove_concurrent_index_by_name(:issues, index_name_for("issues")) + remove_concurrent_index_by_name(:merge_requests, index_name_for("merge_requests")) + end + + def index_name_for(table) + "idx_on_#{table}_where_state_id_is_null" + end +end |
