~launchpad-pqm/launchpad/devel

7675.395.10 by Stuart Bishop
Pending DB patch for CodeImport url collapse, per https://code.launchpad.net/~jelmer/launchpad/hg-import-schema/+merge/15061
1
SET client_min_messages=ERROR;
2
3
ALTER TABLE CodeImport DROP CONSTRAINT valid_vcs_details;
4
5
ALTER TABLE CodeImport RENAME svn_branch_url TO url;
6
7
-- We seem to have leaked some whitespace. Fix it.
8
UPDATE CodeImport SET url = trim(url)
9
    WHERE url IS NOT NULL AND trim(url) <> url;
10
11
UPDATE CodeImport SET url = trim(git_repo_url) WHERE rcs_type = 4;
12
13
ALTER TABLE CodeImport DROP COLUMN git_repo_url;
14
15
DROP INDEX codeimport__svn_branch_url__idx;
16
17
ALTER TABLE CodeImport
18
    ADD CONSTRAINT codeimport__url__key UNIQUE (url),
19
    -- We may want to collapse the CVS details into the URL too at some
20
    -- point too.
21
    ADD CONSTRAINT valid_vcs_details CHECK (
22
        CASE
23
            WHEN rcs_type = 1 THEN
24
                cvs_root IS NOT NULL AND cvs_root <> ''
25
                AND cvs_module IS NOT NULL AND cvs_module <> ''
26
                AND url IS NULL
27
            ELSE
28
                cvs_root IS NULL AND cvs_module IS NULL
29
                AND url IS NOT NULL AND valid_absolute_url(url)
30
        END);
31
32
INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 13, 0);
33