diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 11:11:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 11:11:44 +0000 |
commit | 25989ab7ef1a444ed2abd5479f176d58e1d9462a (patch) | |
tree | 271bb24f3c7178f320cb9de0be0833a285327d09 /db | |
parent | 9bbb32b29703f3ce33dd35d5101145774b793a6d (diff) | |
download | gitlab-ce-25989ab7ef1a444ed2abd5479f176d58e1d9462a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
5 files changed, 176 insertions, 2 deletions
diff --git a/db/migrate/20190927055500_create_description_versions.rb b/db/migrate/20190927055500_create_description_versions.rb new file mode 100644 index 00000000000..6ad34d4a89e --- /dev/null +++ b/db/migrate/20190927055500_create_description_versions.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreateDescriptionVersions < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + create_table :description_versions do |t| + t.timestamps_with_timezone + t.references :issue, index: false, foreign_key: { on_delete: :cascade }, type: :integer + t.references :merge_request, index: false, foreign_key: { on_delete: :cascade }, type: :integer + t.references :epic, index: false, foreign_key: { on_delete: :cascade }, type: :integer + t.text :description + end + + add_index :description_versions, :issue_id, where: 'issue_id IS NOT NULL' + add_index :description_versions, :merge_request_id, where: 'merge_request_id IS NOT NULL' + add_index :description_versions, :epic_id, where: 'epic_id IS NOT NULL' + + add_column :system_note_metadata, :description_version_id, :bigint + end + + def down + remove_column :system_note_metadata, :description_version_id + + drop_table :description_versions + end +end diff --git a/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb b/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb new file mode 100644 index 00000000000..695ba955043 --- /dev/null +++ b/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexToSytemNoteMetadataDescriptionVersionId < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :system_note_metadata, :description_version_id, unique: true, where: 'description_version_id IS NOT NULL' + add_concurrent_foreign_key :system_note_metadata, :description_versions, column: :description_version_id, on_delete: :nullify + end + + def down + remove_foreign_key :system_note_metadata, column: :description_version_id + remove_concurrent_index :system_note_metadata, :description_version_id + end +end diff --git a/db/migrate/20191008180203_add_issuable_state_id_indexes.rb b/db/migrate/20191008180203_add_issuable_state_id_indexes.rb new file mode 100644 index 00000000000..a9a8b8b6359 --- /dev/null +++ b/db/migrate/20191008180203_add_issuable_state_id_indexes.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +class AddIssuableStateIdIndexes < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + # Creates the same indexes that are currently using state:string column + # for issues and merge_requests tables + create_indexes_for_issues + create_indexes_for_merge_requests + end + + def down + # Removes indexes for issues + remove_concurrent_index_by_name :issues, 'idx_issues_on_state_id' + remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_created_at_and_id_and_state_id' + remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_due_date_and_id_and_state_id' + remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_rel_position_and_state_id_and_id' + remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_updated_at_and_id_and_state_id' + + # Removes indexes from merge_requests + remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_id_and_merge_jid' + remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_source_project_and_branch_state_opened' + remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_state_id_and_merge_status' + remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_target_project_id_and_iid_opened' + end + + def create_indexes_for_issues + add_concurrent_index :issues, :state_id, name: 'idx_issues_on_state_id' + + add_concurrent_index :issues, + [:project_id, :created_at, :id, :state_id], + name: 'idx_issues_on_project_id_and_created_at_and_id_and_state_id' + + add_concurrent_index :issues, + [:project_id, :due_date, :id, :state_id], + where: 'due_date IS NOT NULL', + name: 'idx_issues_on_project_id_and_due_date_and_id_and_state_id' + + add_concurrent_index :issues, + [:project_id, :relative_position, :state_id, :id], + order: { id: :desc }, + name: 'idx_issues_on_project_id_and_rel_position_and_state_id_and_id' + + add_concurrent_index :issues, + [:project_id, :updated_at, :id, :state_id], + name: 'idx_issues_on_project_id_and_updated_at_and_id_and_state_id' + end + + def create_indexes_for_merge_requests + add_concurrent_index :merge_requests, + [:id, :merge_jid], + where: 'merge_jid IS NOT NULL and state_id = 4', + name: 'idx_merge_requests_on_id_and_merge_jid' + + add_concurrent_index :merge_requests, + [:source_project_id, :source_branch], + where: 'state_id = 1', + name: 'idx_merge_requests_on_source_project_and_branch_state_opened' + + add_concurrent_index :merge_requests, + [:state_id, :merge_status], + where: "state_id = 1 AND merge_status = 'can_be_merged'", + name: 'idx_merge_requests_on_state_id_and_merge_status' + + add_concurrent_index :merge_requests, + [:target_project_id, :iid], + where: 'state_id = 1', + name: 'idx_merge_requests_on_target_project_id_and_iid_opened' + end +end diff --git a/db/migrate/20191008200204_add_state_id_default_value.rb b/db/migrate/20191008200204_add_state_id_default_value.rb new file mode 100644 index 00000000000..15a80163ca8 --- /dev/null +++ b/db/migrate/20191008200204_add_state_id_default_value.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddStateIdDefaultValue < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + change_column_default :issues, :state_id, 1 + change_column_null :issues, :state_id, false + change_column_default :merge_requests, :state_id, 1 + change_column_null :merge_requests, :state_id, false + end + + def down + change_column_default :issues, :state_id, nil + change_column_null :issues, :state_id, true + change_column_default :merge_requests, :state_id, nil + change_column_null :merge_requests, :state_id, true + end +end diff --git a/db/schema.rb b/db/schema.rb index e43eaef911d..ef9cd696db5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1266,6 +1266,18 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do t.index ["project_id", "status"], name: "index_deployments_on_project_id_and_status" end + create_table "description_versions", force: :cascade do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "issue_id" + t.integer "merge_request_id" + t.integer "epic_id" + t.text "description" + t.index ["epic_id"], name: "index_description_versions_on_epic_id", where: "(epic_id IS NOT NULL)" + t.index ["issue_id"], name: "index_description_versions_on_issue_id", where: "(issue_id IS NOT NULL)" + t.index ["merge_request_id"], name: "index_description_versions_on_merge_request_id", where: "(merge_request_id IS NOT NULL)" + end + create_table "design_management_designs", force: :cascade do |t| t.integer "project_id", null: false t.integer "issue_id" @@ -1916,7 +1928,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do t.boolean "discussion_locked" t.datetime_with_timezone "closed_at" t.integer "closed_by_id" - t.integer "state_id", limit: 2 + t.integer "state_id", limit: 2, default: 1, null: false t.integer "duplicated_to_id" t.index ["author_id"], name: "index_issues_on_author_id" t.index ["closed_by_id"], name: "index_issues_on_closed_by_id" @@ -1926,12 +1938,17 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do t.index ["milestone_id"], name: "index_issues_on_milestone_id" t.index ["moved_to_id"], name: "index_issues_on_moved_to_id", where: "(moved_to_id IS NOT NULL)" t.index ["project_id", "created_at", "id", "state"], name: "index_issues_on_project_id_and_created_at_and_id_and_state" + t.index ["project_id", "created_at", "id", "state_id"], name: "idx_issues_on_project_id_and_created_at_and_id_and_state_id" t.index ["project_id", "due_date", "id", "state"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_partial", where: "(due_date IS NOT NULL)" + t.index ["project_id", "due_date", "id", "state_id"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_id", where: "(due_date IS NOT NULL)" t.index ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true t.index ["project_id", "relative_position", "state", "id"], name: "index_issues_on_project_id_and_rel_position_and_state_and_id", order: { id: :desc } + t.index ["project_id", "relative_position", "state_id", "id"], name: "idx_issues_on_project_id_and_rel_position_and_state_id_and_id", order: { id: :desc } t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state" + t.index ["project_id", "updated_at", "id", "state_id"], name: "idx_issues_on_project_id_and_updated_at_and_id_and_state_id" t.index ["relative_position"], name: "index_issues_on_relative_position" t.index ["state"], name: "index_issues_on_state" + t.index ["state_id"], name: "idx_issues_on_state_id" t.index ["title"], name: "index_issues_on_title_trigram", opclass: :gin_trgm_ops, using: :gin t.index ["updated_at"], name: "index_issues_on_updated_at" t.index ["updated_by_id"], name: "index_issues_on_updated_by_id", where: "(updated_by_id IS NOT NULL)" @@ -2276,23 +2293,27 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do t.boolean "discussion_locked" t.integer "latest_merge_request_diff_id" t.boolean "allow_maintainer_to_push" - t.integer "state_id", limit: 2 + t.integer "state_id", limit: 2, default: 1, null: false t.string "rebase_jid" t.index ["assignee_id"], name: "index_merge_requests_on_assignee_id" t.index ["author_id"], name: "index_merge_requests_on_author_id" t.index ["created_at"], name: "index_merge_requests_on_created_at" t.index ["description"], name: "index_merge_requests_on_description_trigram", opclass: :gin_trgm_ops, using: :gin t.index ["head_pipeline_id"], name: "index_merge_requests_on_head_pipeline_id" + t.index ["id", "merge_jid"], name: "idx_merge_requests_on_id_and_merge_jid", where: "((merge_jid IS NOT NULL) AND (state_id = 4))" t.index ["id", "merge_jid"], name: "index_merge_requests_on_id_and_merge_jid", where: "((merge_jid IS NOT NULL) AND ((state)::text = 'locked'::text))" t.index ["latest_merge_request_diff_id"], name: "index_merge_requests_on_latest_merge_request_diff_id" t.index ["merge_user_id"], name: "index_merge_requests_on_merge_user_id", where: "(merge_user_id IS NOT NULL)" t.index ["milestone_id"], name: "index_merge_requests_on_milestone_id" t.index ["source_branch"], name: "index_merge_requests_on_source_branch" + t.index ["source_project_id", "source_branch"], name: "idx_merge_requests_on_source_project_and_branch_state_opened", where: "(state_id = 1)" t.index ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_and_branch_state_opened", where: "((state)::text = 'opened'::text)" t.index ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_id_and_source_branch" t.index ["state", "merge_status"], name: "index_merge_requests_on_state_and_merge_status", where: "(((state)::text = 'opened'::text) AND ((merge_status)::text = 'can_be_merged'::text))" + t.index ["state_id", "merge_status"], name: "idx_merge_requests_on_state_id_and_merge_status", where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))" t.index ["target_branch"], name: "index_merge_requests_on_target_branch" t.index ["target_project_id", "created_at"], name: "index_merge_requests_target_project_id_created_at" + t.index ["target_project_id", "iid"], name: "idx_merge_requests_on_target_project_id_and_iid_opened", where: "(state_id = 1)" t.index ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true t.index ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid_opened", where: "((state)::text = 'opened'::text)" t.index ["target_project_id", "merge_commit_sha", "id"], name: "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id" @@ -3494,6 +3515,8 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do t.string "action" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "description_version_id" + t.index ["description_version_id"], name: "index_system_note_metadata_on_description_version_id", unique: true, where: "(description_version_id IS NOT NULL)" t.index ["note_id"], name: "index_system_note_metadata_on_note_id", unique: true end @@ -4089,6 +4112,9 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do add_foreign_key "deploy_keys_projects", "projects", name: "fk_58a901ca7e", on_delete: :cascade add_foreign_key "deployments", "clusters", name: "fk_289bba3222", on_delete: :nullify add_foreign_key "deployments", "projects", name: "fk_b9a3851b82", on_delete: :cascade + add_foreign_key "description_versions", "epics", on_delete: :cascade + add_foreign_key "description_versions", "issues", on_delete: :cascade + add_foreign_key "description_versions", "merge_requests", on_delete: :cascade add_foreign_key "design_management_designs", "issues", on_delete: :cascade add_foreign_key "design_management_designs", "projects", on_delete: :cascade add_foreign_key "design_management_designs_versions", "design_management_designs", column: "design_id", name: "fk_03c671965c", on_delete: :cascade @@ -4325,6 +4351,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_220135) do add_foreign_key "software_license_policies", "software_licenses", on_delete: :cascade add_foreign_key "subscriptions", "projects", on_delete: :cascade add_foreign_key "suggestions", "notes", on_delete: :cascade + add_foreign_key "system_note_metadata", "description_versions", name: "fk_fbd87415c9", on_delete: :nullify add_foreign_key "system_note_metadata", "notes", name: "fk_d83a918cb1", on_delete: :cascade add_foreign_key "term_agreements", "application_setting_terms", column: "term_id" add_foreign_key "term_agreements", "users", on_delete: :cascade |