summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 18:08:08 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 18:08:08 +0000
commit83731155d997ae24c7e0cd5ffa6f0dba41bec6dc (patch)
tree31f785012137fda4ac9a470f4f07c961b42d0299 /db
parent57a37ce99f297cddae12cb4d982b6d572f932bb4 (diff)
downloadgitlab-ce-83731155d997ae24c7e0cd5ffa6f0dba41bec6dc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20200127111953_cleanup_empty_snippet_user_mentions.rb28
-rw-r--r--db/post_migrate/20200127131953_migrate_snippet_mentions_to_db.rb35
-rw-r--r--db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb20
-rw-r--r--db/post_migrate/20200127151953_migrate_snippet_notes_mentions_to_db.rb38
-rw-r--r--db/schema.rb1
5 files changed, 0 insertions, 122 deletions
diff --git a/db/post_migrate/20200127111953_cleanup_empty_snippet_user_mentions.rb b/db/post_migrate/20200127111953_cleanup_empty_snippet_user_mentions.rb
deleted file mode 100644
index aad688fef3f..00000000000
--- a/db/post_migrate/20200127111953_cleanup_empty_snippet_user_mentions.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-class CleanupEmptySnippetUserMentions < ActiveRecord::Migration[5.2]
- DOWNTIME = false
- BATCH_SIZE = 10_000
-
- class SnippetUserMention < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'snippet_user_mentions'
- end
-
- def up
- # cleanup snippet user mentions with no actual mentions,
- # re https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24586#note_285982468
- SnippetUserMention
- .where(mentioned_users_ids: nil)
- .where(mentioned_groups_ids: nil)
- .where(mentioned_projects_ids: nil)
- .each_batch(of: BATCH_SIZE) do |batch|
- batch.delete_all
- end
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/post_migrate/20200127131953_migrate_snippet_mentions_to_db.rb b/db/post_migrate/20200127131953_migrate_snippet_mentions_to_db.rb
deleted file mode 100644
index e25c2c2982a..00000000000
--- a/db/post_migrate/20200127131953_migrate_snippet_mentions_to_db.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-class MigrateSnippetMentionsToDb < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- DELAY = 2.minutes.to_i
- BATCH_SIZE = 10_000
- MIGRATION = 'UserMentions::CreateResourceUserMention'
-
- JOIN = "LEFT JOIN snippet_user_mentions on snippets.id = snippet_user_mentions.snippet_id"
- QUERY_CONDITIONS = "(description like '%@%' OR title like '%@%') AND snippet_user_mentions.snippet_id IS NULL"
-
- disable_ddl_transaction!
-
- class Snippet < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'snippets'
- end
-
- def up
- Snippet
- .joins(JOIN)
- .where(QUERY_CONDITIONS)
- .each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(snippets.id)'), Arel.sql('MAX(snippets.id)')).first
- migrate_in(index * DELAY, MIGRATION, ['Snippet', JOIN, QUERY_CONDITIONS, false, *range])
- end
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb b/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb
deleted file mode 100644
index ec9b8b76f6f..00000000000
--- a/db/post_migrate/20200127141953_add_temporary_snippet_notes_with_mentions_index.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class AddTemporarySnippetNotesWithMentionsIndex < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- INDEX_NAME = 'snippet_mentions_temp_index'
- INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'Snippet'"
-
- disable_ddl_transaction!
-
- def up
- # create temporary index for notes with mentions, may take well over 1h
- add_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME)
- end
-
- def down
- remove_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME)
- end
-end
diff --git a/db/post_migrate/20200127151953_migrate_snippet_notes_mentions_to_db.rb b/db/post_migrate/20200127151953_migrate_snippet_notes_mentions_to_db.rb
deleted file mode 100644
index 3795a96b426..00000000000
--- a/db/post_migrate/20200127151953_migrate_snippet_notes_mentions_to_db.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-class MigrateSnippetNotesMentionsToDb < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- DELAY = 2.minutes.to_i
- BATCH_SIZE = 10_000
- MIGRATION = 'UserMentions::CreateResourceUserMention'
-
- INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'Snippet'"
- QUERY_CONDITIONS = "#{INDEX_CONDITION} AND snippet_user_mentions.snippet_id IS NULL"
- JOIN = 'INNER JOIN snippets ON snippets.id = notes.noteable_id LEFT JOIN snippet_user_mentions ON notes.id = snippet_user_mentions.note_id'
-
- disable_ddl_transaction!
-
- class Note < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'notes'
- end
-
- def up
- Note
- .joins(JOIN)
- .where(QUERY_CONDITIONS)
- .each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(notes.id)'), Arel.sql('MAX(notes.id)')).first
- migrate_in(index * DELAY, MIGRATION, ['Snippet', JOIN, QUERY_CONDITIONS, true, *range])
- end
- end
-
- def down
- # no-op
- # temporary index is to be dropped in a different migration in an upcoming release:
- # https://gitlab.com/gitlab-org/gitlab/issues/196842
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index a9cc6d89c6d..8cfa949548f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2838,7 +2838,6 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.index ["discussion_id"], name: "index_notes_on_discussion_id"
t.index ["id"], name: "design_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'DesignManagement::Design'::text))"
t.index ["id"], name: "epic_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'Epic'::text))"
- t.index ["id"], name: "snippet_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'Snippet'::text))"
t.index ["line_code"], name: "index_notes_on_line_code"
t.index ["note"], name: "index_notes_on_note_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["note"], name: "tmp_idx_on_promoted_notes", where: "(((noteable_type)::text = 'Issue'::text) AND (system IS TRUE) AND (note ~~ 'promoted to epic%'::text))"