Commit f9a0de9e authored by James Fargher's avatar James Fargher

Merge branch 'steal-fix-project-names-background-migration' into 'master'

Create unique index on projects namespace_id and name

See merge request gitlab-org/gitlab!83884
parents 83e00716 16502ac5
# frozen_string_literal: true
class StealBackgroundJobForFixingConflictingProjectNamesAndPaths < Gitlab::Database::Migration[1.0]
def up
Gitlab::BackgroundMigration.steal('FixDuplicateProjectNameAndPath')
end
def down
# no-op
end
end
# frozen_string_literal: true
class CreateUniqueIndexOnProjectsNameAndNamespaceId < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'unique_projects_on_name_namespace_id'
disable_ddl_transaction!
def up
add_concurrent_index :projects, [:name, :namespace_id], unique: true, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :projects, INDEX_NAME
end
end
bbcd27340d9d684b6134292772dad6f523ce6e1af9853ce12284a0c138d6b7bd
\ No newline at end of file
7f33fc1c6b47e3ff732caa62d15f0d725c03d993eacb24bc603992fc2579e63c
\ No newline at end of file
......@@ -29685,6 +29685,8 @@ CREATE UNIQUE INDEX uniq_pkgs_debian_project_distributions_project_id_and_suite
CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_request_metrics USING btree (merge_request_id);
CREATE UNIQUE INDEX unique_projects_on_name_namespace_id ON projects USING btree (name, namespace_id);
CREATE INDEX user_follow_users_followee_id_idx ON user_follow_users USING btree (followee_id);
CREATE INDEX users_forbidden_state_idx ON users USING btree (id) WHERE ((confirmed_at IS NOT NULL) AND ((state)::text <> ALL (ARRAY['blocked'::text, 'banned'::text, 'ldap_blocked'::text])));
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::FixDuplicateProjectNameAndPath, :migration do
RSpec.describe Gitlab::BackgroundMigration::FixDuplicateProjectNameAndPath, :migration, schema: 20220325155953 do
let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
......
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