Add unique constraint to trending_projects#project_id.
This turns an existing index on trending_projects#project_id
into a UNIQUE
index. See https://gitlab.com/gitlab-org/gitlab-ce/issues/32283.
Database Checklist
When adding migrations:
-
Updated db/schema.rb
-
Added a down
method so the migration can be reverted -
Added the output of the migration(s) to the MR body -
Added tests for the migration inspec/migrations
if necessary (e.g. when migrating data)
$ rake db:migrate
== 20180201102129 AddUniqueConstraintToTrendingProjectsProjectId: migrating ===
-- transaction_open?()
-> 0.0000s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- add_index(:trending_projects, :project_id, {:unique=>true, :name=>"index_trending_projects_on_project_id_unique", :algorithm=>:concurrently})
-> 0.0078s
-- transaction_open?()
-> 0.0000s
-- select_one("SELECT current_setting('server_version_num') AS v")
-> 0.0004s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- remove_index(:trending_projects, {:algorithm=>:concurrently, :name=>"index_trending_projects_on_project_id"})
-> 0.0023s
-- rename_index(:trending_projects, "index_trending_projects_on_project_id_unique", "index_trending_projects_on_project_id")
-> 0.0012s
== 20180201102129 AddUniqueConstraintToTrendingProjectsProjectId: migrated (0.0126s)
General Checklist
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added -
Tests added for this feature/bug - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together
Edited by Yorick Peterse