Commit e30c8414 authored by Toon Claes's avatar Toon Claes Committed by Douglas Barbosa Alexandre

Undo adding foreign key on geo_event_log.hashed_storage_attachments_event_id

parent dcffe1f7
......@@ -3283,7 +3283,6 @@ ActiveRecord::Schema.define(version: 20181105201455) do
add_foreign_key "fork_networks", "projects", column: "root_project_id", name: "fk_e7b436b2b5", on_delete: :nullify
add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_cache_invalidation_events", column: "cache_invalidation_event_id", name: "fk_42c3b54bed", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_hashed_storage_attachments_events", column: "hashed_storage_attachments_event_id", name: "fk_304067fc30", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_hashed_storage_migrated_events", column: "hashed_storage_migrated_event_id", name: "fk_27548c6db3", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_job_artifact_deleted_events", column: "job_artifact_deleted_event_id", name: "fk_176d3fbb5d", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_lfs_object_deleted_events", column: "lfs_object_deleted_event_id", name: "fk_d5af95fcd9", on_delete: :cascade
......
......@@ -18,8 +18,6 @@ class AddMissingGeoEvenLogIndexes < ActiveRecord::Migration
job_artifact_deleted_event_id
upload_deleted_event_id]
MISSING_FK_COLUMNS = %i[hashed_storage_attachments_event_id]
disable_ddl_transaction!
def up
......@@ -35,22 +33,9 @@ class AddMissingGeoEvenLogIndexes < ActiveRecord::Migration
NON_INDEXED_COLUMNS.each do |col|
add_concurrent_index_not_null(:geo_event_log, col)
end
# Add missing foreign keys
MISSING_FK_COLUMNS.each do |col|
add_concurrent_foreign_key(:geo_event_log,
foreign_table_name(col),
column: col,
on_delete: :cascade)
end
end
def down
# Remove missing foreign keys again
MISSING_FK_COLUMNS.each do |col|
remove_foreign_key(:geo_event_log, column: col)
end
# Drop indexes that didn't exist before
NON_INDEXED_COLUMNS.each do |col|
without_foreign_key(:geo_event_log, col) do
......
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('ee', 'db', 'migrate', '20181017131623_add_missing_geo_even_log_indexes.rb')
describe AddMissingGeoEvenLogIndexes, :migration do
let(:namespace) { table(:namespaces).create(path: 'ns', name: 'Namespace') }
let(:project) { table(:projects).create(namespace_id: namespace.id, path: 'pj') }
let(:geo_event_log) { table(:geo_event_log) }
let(:updated_event) do
table(:geo_repository_updated_events).create(
project_id: project.id,
source: 0,
branches_affected: 0,
tags_affected: 0)
end
let(:hashed_attachment_event) do
table(:geo_hashed_storage_attachments_events).create(
project_id: project.id,
old_attachments_path: '/tmp/foo/bar',
new_attachments_path: '/tmp/foo/baz')
end
describe '#up' do
it 'adds indexes' do
schema_migrate_up!
end
end
describe '#down' do
it 'rolls back indexes' do
schema_migrate_down!
end
end
end
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