Merge lp:~cjwatson/launchpad/db-codeimport-git-url-per-target-rcs into lp:launchpad/db-devel

Proposed by Colin Watson
Status: Superseded
Proposed branch: lp:~cjwatson/launchpad/db-codeimport-git-url-per-target-rcs
Merge into: lp:launchpad/db-devel
Diff against target: 16 lines (+12/-0)
1 file modified
database/schema/patch-2209-80-1.sql (+12/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/db-codeimport-git-url-per-target-rcs
Reviewer Review Type Date Requested Status
William Grant db Approve
Review via email: mp+310695@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-15.

Commit message

Split the unique CodeImport(url) index into one for each target RCS type.

Description of the change

See https://code.launchpad.net/~cjwatson/launchpad/codeimport-git-url-per-target-rcs/+merge/310696 for rationale.

This can't be applied hot since it needs to drop an existing index.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Why can't this be applied hot? DROP INDEX CONCURRENTLY is a thing -- we should just do it in the other order.

review: Approve (db)
Revision history for this message
Colin Watson (cjwatson) wrote :

I was going from the comment about deleting indexes on https://dev.launchpad.net/Database/LivePatching, but also, https://www.postgresql.org/docs/9.3/static/sql-dropindex.html says that you can't drop UNIQUE indexes with DROP INDEX CONCURRENTLY. However, testing on dogfood would appear to disagree, so sure, let's do it hot.

Switching the order seems like a good plan either way.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2209-80-1.sql'
2--- database/schema/patch-2209-80-1.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-80-1.sql 2016-11-12 02:33:33 +0000
4@@ -0,0 +1,12 @@
5+-- Copyright 2016 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+SET client_min_messages=ERROR;
9+
10+DROP INDEX codeimport__url__idx;
11+CREATE UNIQUE INDEX codeimport__url__branch__idx
12+ ON CodeImport(url) WHERE branch IS NOT NULL;
13+CREATE UNIQUE INDEX codeimport__url__git_repository__idx
14+ ON CodeImport(url) WHERE git_repository IS NOT NULL;
15+
16+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 80, 1);

Subscribers

People subscribed via source and target branches

to status/vote changes: