summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-19 11:06:47 -0700
committerStan Hu <stanhu@gmail.com>2019-06-19 13:30:41 -0700
commit6c0bc9abdd2542cc0951bd34b150a5824b987636 (patch)
tree45ebaac4246f5c5b95e1973035a49533d174c96b
parent4a5bda06900b2b623f7f9fcdce6b36cdcf73bc51 (diff)
downloadgitlab-ce-sh-remove-import-columns-from-projects.tar.gz
Remove import columns from projects tablesh-remove-import-columns-from-projects
In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21497, we migrated all project import data into a separate table, `project_import_data`. In addition, we also added: ``` ignore_column :import_status, :import_jid, :import_error ``` In https://gitlab.com/gitlab-com/gl-infra/production/issues/908, we observed some of these `import_error` columns consumed megabytes of error backtraces and caused slow loading of projects whenever a `SELECT * from projects` query loaded the row into memory. Since we have long migrated away from these columns, we can now drop these columns entirely.
-rw-r--r--app/models/project.rb2
-rw-r--r--changelogs/unreleased/sh-remove-import-columns-from-projects.yml5
-rw-r--r--db/post_migrate/20190619175843_remove_import_columns_from_projects.rb14
-rw-r--r--db/schema.rb5
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb4
5 files changed, 22 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 351d08eaf63..7851f37116c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -55,8 +55,6 @@ class Project < ApplicationRecord
VALID_MIRROR_PORTS = [22, 80, 443].freeze
VALID_MIRROR_PROTOCOLS = %w(http https ssh git).freeze
- ignore_column :import_status, :import_jid, :import_error
-
cache_markdown_field :description, pipeline: :description
delegate :feature_available?, :builds_enabled?, :wiki_enabled?,
diff --git a/changelogs/unreleased/sh-remove-import-columns-from-projects.yml b/changelogs/unreleased/sh-remove-import-columns-from-projects.yml
new file mode 100644
index 00000000000..f4052b2bef5
--- /dev/null
+++ b/changelogs/unreleased/sh-remove-import-columns-from-projects.yml
@@ -0,0 +1,5 @@
+---
+title: Remove import columns from projects table
+merge_request: 29863
+author:
+type: performance
diff --git a/db/post_migrate/20190619175843_remove_import_columns_from_projects.rb b/db/post_migrate/20190619175843_remove_import_columns_from_projects.rb
new file mode 100644
index 00000000000..85f776ac99c
--- /dev/null
+++ b/db/post_migrate/20190619175843_remove_import_columns_from_projects.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class RemoveImportColumnsFromProjects < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ remove_column :projects, :import_status, :string
+ remove_column :projects, :import_jid, :string
+ remove_column :projects, :import_error, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7a7319c132e..4e333633a8b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20190613030606) do
+ActiveRecord::Schema.define(version: 20190619175843) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -2595,11 +2595,9 @@ ActiveRecord::Schema.define(version: 20190613030606) do
t.integer "visibility_level", default: 0, null: false
t.boolean "archived", default: false, null: false
t.string "avatar"
- t.string "import_status"
t.integer "star_count", default: 0, null: false
t.string "import_type"
t.string "import_source"
- t.text "import_error"
t.boolean "shared_runners_enabled", default: true, null: false
t.string "runners_token"
t.string "build_coverage_regex"
@@ -2621,7 +2619,6 @@ ActiveRecord::Schema.define(version: 20190613030606) do
t.boolean "only_allow_merge_if_all_discussions_are_resolved"
t.boolean "printing_merge_request_link_enabled", default: true, null: false
t.integer "auto_cancel_pending_pipelines", default: 1, null: false
- t.string "import_jid"
t.integer "cached_markdown_version"
t.text "delete_error"
t.datetime "last_repository_updated_at"
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 1e4c4c38f74..3cf3d032bf4 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -461,9 +461,9 @@ describe Gitlab::Database::MigrationHelpers do
end
it 'updates all the rows in a table' do
- model.update_column_in_batches(:projects, :import_error, 'foo')
+ model.update_column_in_batches(:projects, :description_html, 'foo')
- expect(Project.where(import_error: 'foo').count).to eq(5)
+ expect(Project.where(description_html: 'foo').count).to eq(5)
end
it 'updates boolean values correctly' do