Commit 390bb6db authored by Michael Kozono's avatar Michael Kozono

Remove uniqueness constraint from url

So that secondaries can use the same URL.
parent 08489450
......@@ -1389,7 +1389,6 @@ ActiveRecord::Schema.define(version: 20190426180107) do
t.index ["access_key"], name: "index_geo_nodes_on_access_key", using: :btree
t.index ["name"], name: "index_geo_nodes_on_name", unique: true, using: :btree
t.index ["primary"], name: "index_geo_nodes_on_primary", using: :btree
t.index ["url"], name: "index_geo_nodes_on_url", unique: true, using: :btree
end
create_table "geo_repositories_changed_events", force: :cascade do |t|
......
......@@ -16,7 +16,7 @@ class GeoNode < ApplicationRecord
has_one :status, class_name: 'GeoNodeStatus'
validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :url, presence: true, uniqueness: { case_sensitive: false }, addressable_url: true
validates :url, presence: true, addressable_url: true
validates :internal_url, addressable_url: true, allow_blank: true, allow_nil: true
validates :primary, uniqueness: { message: 'node already exists' }, if: :primary
......
# 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 RemoveUrlIndexFromGeoNodes < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :geo_nodes, :url
end
def down
add_concurrent_index :geo_nodes, :url, unique: true
end
end
......@@ -32,7 +32,6 @@ describe GeoNode, :geo, type: :model do
it { is_expected.to validate_numericality_of(:minimum_reverification_interval).is_greater_than_or_equal_to(1) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_uniqueness_of(:url).case_insensitive }
it { is_expected.to validate_uniqueness_of(:name).case_insensitive }
context 'when validating primary node' do
......@@ -64,6 +63,13 @@ describe GeoNode, :geo, type: :model do
it { is_expected.not_to be_valid }
end
context 'when an existing GeoNode has the same url but different name' do
let!(:existing) { new_node }
let(:url) { new_node.url }
it { is_expected.to be_valid }
end
end
context 'when validating internal_url' do
......
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