Commit 5975f55c authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'fix-events-migration' into 'master'

Add index on group_id column concurrently

See merge request gitlab-org/gitlab-ce!32826
parents eb2afea2 b9657ed1
# frozen_string_literal: true # frozen_string_literal: true
class AddGroupColumnToEvents < ActiveRecord::Migration[5.2] class AddGroupColumnToEvents < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
def change disable_ddl_transaction!
add_reference :events, :group, index: true, foreign_key: { to_table: :namespaces, on_delete: :cascade }
def up
add_column(:events, :group_id, :bigint) unless column_exists?(:events, :group_id)
add_concurrent_index(:events, :group_id)
add_concurrent_foreign_key(:events, :namespaces, column: :group_id, on_delete: :cascade)
end
def down
remove_column(:events, :group_id) if column_exists?(:events, :group_id)
end end
end end
...@@ -3864,7 +3864,7 @@ ActiveRecord::Schema.define(version: 2019_09_05_223900) do ...@@ -3864,7 +3864,7 @@ ActiveRecord::Schema.define(version: 2019_09_05_223900) do
add_foreign_key "epics", "users", column: "assignee_id", name: "fk_dccd3f98fc", on_delete: :nullify add_foreign_key "epics", "users", column: "assignee_id", name: "fk_dccd3f98fc", on_delete: :nullify
add_foreign_key "epics", "users", column: "author_id", name: "fk_3654b61b03", on_delete: :cascade add_foreign_key "epics", "users", column: "author_id", name: "fk_3654b61b03", on_delete: :cascade
add_foreign_key "epics", "users", column: "closed_by_id", name: "fk_aa5798e761", on_delete: :nullify add_foreign_key "epics", "users", column: "closed_by_id", name: "fk_aa5798e761", on_delete: :nullify
add_foreign_key "events", "namespaces", column: "group_id", on_delete: :cascade add_foreign_key "events", "namespaces", column: "group_id", name: "fk_61fbf6ca48", on_delete: :cascade
add_foreign_key "events", "projects", on_delete: :cascade add_foreign_key "events", "projects", on_delete: :cascade
add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade
add_foreign_key "external_pull_requests", "projects", on_delete: :cascade add_foreign_key "external_pull_requests", "projects", on_delete: :cascade
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment