Skip to content

Create unique index on projects namespace_id and name

After fixing conflicting project names within !83587 (merged) we should be able to add a unique index on projects table on [name, namespace_id] column pair to prevent this from happening in the future re !83587 (comment 892863376)

This MR is dependent on !83587 (merged) and needs to be merged after !83587 (diffs) is merged.

Also this migration timestamps(20220325155953, 20220325160153) are set to run after migration in !83587 (merged) (20220324081709)

Database

UP

== 20220325155953 StealBackgroundJobForFixingConflictingProjectNamesAndPaths: migrating
== 20220325155953 StealBackgroundJobForFixingConflictingProjectNamesAndPaths: migrated (0.0110s)

== 20220325160153 CreateUniqueIndexOnProjectsNameAndNamespaceId: migrating ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:projects, [:name, :namespace_id], {:unique=>true, :name=>"unique_projects_on_name_namespace_id", :algorithm=>:concurrently})
   -> 0.0366s
-- execute("SET statement_timeout TO 0")
   -> 0.0006s
-- add_index(:projects, [:name, :namespace_id], {:unique=>true, :name=>"unique_projects_on_name_namespace_id", :algorithm=>:concurrently})
   -> 0.0097s
-- execute("RESET statement_timeout")
   -> 0.0007s
== 20220325160153 CreateUniqueIndexOnProjectsNameAndNamespaceId: migrated (0.0649s)

DOWN

== 20220325160153 CreateUniqueIndexOnProjectsNameAndNamespaceId: reverting ====
-- transaction_open?()
   -> 0.0001s
-- indexes(:projects)
   -> 0.1489s
-- execute("SET statement_timeout TO 0")
   -> 0.0053s
-- remove_index(:projects, {:algorithm=>:concurrently, :name=>"unique_projects_on_name_namespace_id"})
   -> 0.0222s
-- execute("RESET statement_timeout")
   -> 0.0035s
== 20220325160153 CreateUniqueIndexOnProjectsNameAndNamespaceId: reverted (0.2413s)

== 20220325155953 StealBackgroundJobForFixingConflictingProjectNamesAndPaths: reverting
== 20220325155953 StealBackgroundJobForFixingConflictingProjectNamesAndPaths: reverted (0.0000s)
Edited by Alexandru Croitor

Merge request reports

Loading