diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 00:08:41 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 00:08:41 +0000 |
commit | e40710ab8a30f36d7c82d7d6497033291840eec9 (patch) | |
tree | aea450b24cb1bd8023c1d297e4f01de4e88926b2 /db | |
parent | 51612d3ef5be853289008694c40973b479e8547c (diff) | |
download | gitlab-ce-e40710ab8a30f36d7c82d7d6497033291840eec9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
4 files changed, 111 insertions, 2 deletions
diff --git a/db/migrate/20200129133716_add_resource_milestone_events_table.rb b/db/migrate/20200129133716_add_resource_milestone_events_table.rb new file mode 100644 index 00000000000..0ead21820c2 --- /dev/null +++ b/db/migrate/20200129133716_add_resource_milestone_events_table.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :resource_milestone_events, id: :bigserial do |t| + t.references :user, null: false, foreign_key: { on_delete: :nullify }, + index: { name: 'index_resource_milestone_events_on_user_id' } + t.references :issue, null: true, foreign_key: { on_delete: :cascade }, + index: { name: 'index_resource_milestone_events_on_issue_id' } + t.references :merge_request, null: true, foreign_key: { on_delete: :cascade }, + index: { name: 'index_resource_milestone_events_on_merge_request_id' } + t.references :milestone, foreign_key: { on_delete: :cascade }, + index: { name: 'index_resource_milestone_events_on_milestone_id' } + + t.integer :action, limit: 2, null: false + t.integer :state, limit: 2, null: false + t.integer :cached_markdown_version + t.text :reference + t.text :reference_html + t.datetime_with_timezone :created_at, null: false + end + end +end diff --git a/db/migrate/20200204131054_change_broadcast_message_index.rb b/db/migrate/20200204131054_change_broadcast_message_index.rb new file mode 100644 index 00000000000..9545eacd3a1 --- /dev/null +++ b/db/migrate/20200204131054_change_broadcast_message_index.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class ChangeBroadcastMessageIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :broadcast_messages, %i(ends_at broadcast_type id), name: 'index_broadcast_message_on_ends_at_and_broadcast_type_and_id' + remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_messages_on_starts_at_and_ends_at_and_id + end + + def down + add_concurrent_index :broadcast_messages, %i(starts_at ends_at id), name: 'index_broadcast_messages_on_starts_at_and_ends_at_and_id' + remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_message_on_ends_at_and_broadcast_type_and_id + end +end diff --git a/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb b/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb new file mode 100644 index 00000000000..312a8c95b92 --- /dev/null +++ b/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class RescheduleMigrateIssueTrackersData < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INTERVAL = 3.minutes.to_i + BATCH_SIZE = 5_000 + MIGRATION = 'MigrateIssueTrackersSensitiveData' + + disable_ddl_transaction! + + class Service < ActiveRecord::Base + self.table_name = 'services' + self.inheritance_column = :_type_disabled + + include ::EachBatch + end + + def up + relation = Service.where(category: 'issue_tracker').where("properties IS NOT NULL AND properties != '{}' AND properties != ''") + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION, + INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + remove_issue_tracker_data_sql = "DELETE FROM issue_tracker_data WHERE \ + (length(encrypted_issues_url) > 0 AND encrypted_issues_url_iv IS NULL) \ + OR (length(encrypted_new_issue_url) > 0 AND encrypted_new_issue_url_iv IS NULL) \ + OR (length(encrypted_project_url) > 0 AND encrypted_project_url_iv IS NULL)" + + execute(remove_issue_tracker_data_sql) + + remove_jira_tracker_data_sql = "DELETE FROM jira_tracker_data WHERE \ + (length(encrypted_api_url) > 0 AND encrypted_api_url_iv IS NULL) \ + OR (length(encrypted_url) > 0 AND encrypted_url_iv IS NULL) \ + OR (length(encrypted_username) > 0 AND encrypted_username_iv IS NULL) \ + OR (length(encrypted_password) > 0 AND encrypted_password_iv IS NULL)" + + execute(remove_jira_tracker_data_sql) + end +end diff --git a/db/schema.rb b/db/schema.rb index ecc65944bd8..a61a5533ccf 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: 2020_02_03_025821) do +ActiveRecord::Schema.define(version: 2020_02_04_131054) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -564,7 +564,7 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do t.integer "cached_markdown_version" t.string "target_path", limit: 255 t.integer "broadcast_type", limit: 2, default: 1, null: false - t.index ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id" + t.index ["ends_at", "broadcast_type", "id"], name: "index_broadcast_message_on_ends_at_and_broadcast_type_and_id" end create_table "chat_names", id: :serial, force: :cascade do |t| @@ -3680,6 +3680,23 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do t.index ["user_id"], name: "index_resource_label_events_on_user_id" end + create_table "resource_milestone_events", force: :cascade do |t| + t.bigint "user_id", null: false + t.bigint "issue_id" + t.bigint "merge_request_id" + t.bigint "milestone_id" + t.integer "action", limit: 2, null: false + t.integer "state", limit: 2, null: false + t.integer "cached_markdown_version" + t.text "reference" + t.text "reference_html" + t.datetime_with_timezone "created_at", null: false + t.index ["issue_id"], name: "index_resource_milestone_events_on_issue_id" + t.index ["merge_request_id"], name: "index_resource_milestone_events_on_merge_request_id" + t.index ["milestone_id"], name: "index_resource_milestone_events_on_milestone_id" + t.index ["user_id"], name: "index_resource_milestone_events_on_user_id" + end + create_table "resource_weight_events", force: :cascade do |t| t.bigint "user_id", null: false t.bigint "issue_id", null: false @@ -4842,6 +4859,10 @@ ActiveRecord::Schema.define(version: 2020_02_03_025821) do add_foreign_key "resource_label_events", "labels", on_delete: :nullify add_foreign_key "resource_label_events", "merge_requests", on_delete: :cascade add_foreign_key "resource_label_events", "users", on_delete: :nullify + add_foreign_key "resource_milestone_events", "issues", on_delete: :cascade + add_foreign_key "resource_milestone_events", "merge_requests", on_delete: :cascade + add_foreign_key "resource_milestone_events", "milestones", on_delete: :cascade + add_foreign_key "resource_milestone_events", "users", on_delete: :nullify add_foreign_key "resource_weight_events", "issues", on_delete: :cascade add_foreign_key "resource_weight_events", "users", on_delete: :nullify add_foreign_key "reviews", "merge_requests", on_delete: :cascade |