Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 18:09:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 18:09:21 +0300
commitc36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch)
treebbf300da207de3e8bbf272d44111ceedb18f5833 /db
parent286fe61013674fe2d245ffc8d2233baf09923e70 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200309162244_add_open_project_tracker_data.rb23
-rw-r--r--db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb4
-rw-r--r--db/post_migrate/20200214173000_cleanup_empty_epic_user_mentions.rb30
-rw-r--r--db/post_migrate/20200214174519_remigrate_epic_mentions_to_db.rb38
-rw-r--r--db/post_migrate/20200214174607_remigrate_epic_notes_mentions_to_db.rb45
-rw-r--r--db/schema.rb16
6 files changed, 40 insertions, 116 deletions
diff --git a/db/migrate/20200309162244_add_open_project_tracker_data.rb b/db/migrate/20200309162244_add_open_project_tracker_data.rb
new file mode 100644
index 00000000000..672dde4d518
--- /dev/null
+++ b/db/migrate/20200309162244_add_open_project_tracker_data.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddOpenProjectTrackerData < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :open_project_tracker_data do |t|
+ t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
+ t.timestamps_with_timezone
+ t.string :encrypted_url, limit: 255
+ t.string :encrypted_url_iv, limit: 255
+ t.string :encrypted_api_url, limit: 255
+ t.string :encrypted_api_url_iv, limit: 255
+ t.string :encrypted_token, limit: 255
+ t.string :encrypted_token_iv, limit: 255
+ t.string :closed_status_id, limit: 5
+ t.string :project_identifier_code, limit: 100
+ end
+ end
+end
diff --git a/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb b/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb
index 2cbf7a69159..97f2e568a7e 100644
--- a/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb
+++ b/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true
class MigrateEpicMentionsToDb < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
DOWNTIME = false
disable_ddl_transaction!
@@ -28,7 +26,7 @@ class MigrateEpicMentionsToDb < ActiveRecord::Migration[5.2]
.where(QUERY_CONDITIONS)
.each_batch(of: BATCH_SIZE) do |batch, index|
range = batch.pluck(Arel.sql('MIN(epics.id)'), Arel.sql('MAX(epics.id)')).first
- migrate_in(index * DELAY, MIGRATION, ['Epic', JOIN, QUERY_CONDITIONS, false, *range])
+ BackgroundMigrationWorker.perform_in(index * DELAY, MIGRATION, ['Epic', JOIN, QUERY_CONDITIONS, false, *range])
end
end
diff --git a/db/post_migrate/20200214173000_cleanup_empty_epic_user_mentions.rb b/db/post_migrate/20200214173000_cleanup_empty_epic_user_mentions.rb
deleted file mode 100644
index ef6486675e0..00000000000
--- a/db/post_migrate/20200214173000_cleanup_empty_epic_user_mentions.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-class CleanupEmptyEpicUserMentions < ActiveRecord::Migration[5.2]
- DOWNTIME = false
- BATCH_SIZE = 10000
-
- class EpicUserMention < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'epic_user_mentions'
- end
-
- def up
- return unless Gitlab.ee?
-
- # cleanup epic user mentions with no actual mentions,
- # re https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24586#note_285982468
- EpicUserMention
- .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/20200214174519_remigrate_epic_mentions_to_db.rb b/db/post_migrate/20200214174519_remigrate_epic_mentions_to_db.rb
deleted file mode 100644
index 68fe031be5d..00000000000
--- a/db/post_migrate/20200214174519_remigrate_epic_mentions_to_db.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-class RemigrateEpicMentionsToDb < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- DELAY = 2.minutes.to_i
- BATCH_SIZE = 10000
- MIGRATION = 'UserMentions::CreateResourceUserMention'
-
- JOIN = "LEFT JOIN epic_user_mentions on epics.id = epic_user_mentions.epic_id"
- QUERY_CONDITIONS = "(description like '%@%' OR title like '%@%') AND epic_user_mentions.epic_id is null"
-
- class Epic < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'epics'
- end
-
- def up
- return unless Gitlab.ee?
-
- Epic
- .joins(JOIN)
- .where(QUERY_CONDITIONS)
- .each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck(Arel.sql('MIN(epics.id)'), Arel.sql('MAX(epics.id)')).first
- migrate_in(index * DELAY, MIGRATION, ['Epic', JOIN, QUERY_CONDITIONS, false, *range])
- end
- end
-
- def down
- # no-op
- end
-end
diff --git a/db/post_migrate/20200214174607_remigrate_epic_notes_mentions_to_db.rb b/db/post_migrate/20200214174607_remigrate_epic_notes_mentions_to_db.rb
deleted file mode 100644
index cb442233229..00000000000
--- a/db/post_migrate/20200214174607_remigrate_epic_notes_mentions_to_db.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-
-class RemigrateEpicNotesMentionsToDb < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- DELAY = 2.minutes.to_i
- BATCH_SIZE = 10000
- MIGRATION = 'UserMentions::CreateResourceUserMention'
-
- INDEX_NAME = 'epic_mentions_temp_index'
- INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'Epic'"
- QUERY_CONDITIONS = "#{INDEX_CONDITION} AND epic_user_mentions.epic_id IS NULL"
- JOIN = 'INNER JOIN epics ON epics.id = notes.noteable_id LEFT JOIN epic_user_mentions ON notes.id = epic_user_mentions.note_id'
-
- class Note < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'notes'
- end
-
- def up
- return unless Gitlab.ee?
-
- # create temporary index for notes with mentions, may take well over 1h
- add_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME)
-
- 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, ['Epic', 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 0b261a2461d..a9dcfa50d33 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2921,6 +2921,21 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
t.index ["access_grant_id"], name: "index_oauth_openid_requests_on_access_grant_id"
end
+ create_table "open_project_tracker_data", force: :cascade do |t|
+ t.integer "service_id", null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.string "encrypted_url", limit: 255
+ t.string "encrypted_url_iv", limit: 255
+ t.string "encrypted_api_url", limit: 255
+ t.string "encrypted_api_url_iv", limit: 255
+ t.string "encrypted_token", limit: 255
+ t.string "encrypted_token_iv", limit: 255
+ t.string "closed_status_id", limit: 5
+ t.string "project_identifier_code", limit: 100
+ t.index ["service_id"], name: "index_open_project_tracker_data_on_service_id"
+ end
+
create_table "operations_feature_flag_scopes", force: :cascade do |t|
t.bigint "feature_flag_id", null: false
t.datetime_with_timezone "created_at", null: false
@@ -4993,6 +5008,7 @@ ActiveRecord::Schema.define(version: 2020_03_11_165635) do
add_foreign_key "notes", "reviews", name: "fk_2e82291620", on_delete: :nullify
add_foreign_key "notification_settings", "users", name: "fk_0c95e91db7", on_delete: :cascade
add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", name: "fk_77114b3b09", on_delete: :cascade
+ add_foreign_key "open_project_tracker_data", "services", on_delete: :cascade
add_foreign_key "operations_feature_flag_scopes", "operations_feature_flags", column: "feature_flag_id", on_delete: :cascade
add_foreign_key "operations_feature_flags", "projects", on_delete: :cascade
add_foreign_key "operations_feature_flags_clients", "projects", on_delete: :cascade