1 | -- $Id: tmdb-r13-buildcategories-1-vcsrevisions-1.pgsql 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
2 | --- @file
|
---|
3 | -- VBox Test Manager Database - Adds an sRepository to Builds and creates a new VcsRepositories table.
|
---|
4 | --
|
---|
5 |
|
---|
6 | --
|
---|
7 | -- Copyright (C) 2013-2020 Oracle Corporation
|
---|
8 | --
|
---|
9 | -- This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | -- available from http://www.virtualbox.org. This file is free software;
|
---|
11 | -- you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | -- General Public License (GPL) as published by the Free Software
|
---|
13 | -- Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | -- VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | -- hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | --
|
---|
17 | -- The contents of this file may alternatively be used under the terms
|
---|
18 | -- of the Common Development and Distribution License Version 1.0
|
---|
19 | -- (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | -- VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | -- CDDL are applicable instead of those of the GPL.
|
---|
22 | --
|
---|
23 | -- You may elect to license modified versions of this file under the
|
---|
24 | -- terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | --
|
---|
26 |
|
---|
27 | --
|
---|
28 | -- Cleanup after failed runs.
|
---|
29 | --
|
---|
30 | DROP TABLE NewBuildCategories;
|
---|
31 | DROP TABLE OldBuildCategories;
|
---|
32 |
|
---|
33 | --
|
---|
34 | -- Drop foreign keys on this table.
|
---|
35 | --
|
---|
36 | ALTER TABLE Builds DROP CONSTRAINT NewBuilds_idBuildCategory_fkey;
|
---|
37 | ALTER TABLE Builds DROP CONSTRAINT Builds_idBuildCategory_fkey;
|
---|
38 | ALTER TABLE TestSets DROP CONSTRAINT TestSets_idBuildCategory_fkey;
|
---|
39 |
|
---|
40 | -- Die on error from now on.
|
---|
41 | \set ON_ERROR_STOP 1
|
---|
42 | \set AUTOCOMMIT 0
|
---|
43 |
|
---|
44 | \d+ BuildCategories;
|
---|
45 |
|
---|
46 | --
|
---|
47 | -- Create the new version of the table and filling with the content of the old.
|
---|
48 | --
|
---|
49 | CREATE TABLE NewBuildCategories (
|
---|
50 | --- The build type identifier.
|
---|
51 | idBuildCategory INTEGER PRIMARY KEY DEFAULT NEXTVAL('BuildCategoryIdSeq') NOT NULL,
|
---|
52 | --- Product.
|
---|
53 | -- The product name. For instance 'VBox' or 'VBoxTestSuite'.
|
---|
54 | sProduct TEXT NOT NULL,
|
---|
55 | --- The version control repository name.
|
---|
56 | sRepository TEXT NOT NULL,
|
---|
57 | --- The branch name (in the version control system).
|
---|
58 | sBranch TEXT NOT NULL,
|
---|
59 | --- The build type.
|
---|
60 | -- See KBUILD_BLD_TYPES in kBuild for a list of standard build types.
|
---|
61 | sType TEXT NOT NULL,
|
---|
62 | --- Array of the 'sOs.sCpuArch' supported by the build.
|
---|
63 | -- See KBUILD_OSES in kBuild for a list of standard target OSes, and
|
---|
64 | -- KBUILD_ARCHES for a list of standard architectures.
|
---|
65 | --
|
---|
66 | -- @remarks 'os-agnostic' is used if the build doesn't really target any
|
---|
67 | -- specific OS or if it targets all applicable OSes.
|
---|
68 | -- 'noarch' is used if the build is architecture independent or if
|
---|
69 | -- all applicable architectures are handled.
|
---|
70 | -- Thus, 'os-agnostic.noarch' will run on all build boxes.
|
---|
71 | --
|
---|
72 | -- @note The array shall be sorted ascendingly to prevent unnecessary duplicates!
|
---|
73 | --
|
---|
74 | asOsArches TEXT ARRAY NOT NULL,
|
---|
75 |
|
---|
76 | UNIQUE (sProduct, sRepository, sBranch, sType, asOsArches)
|
---|
77 | );
|
---|
78 | COMMIT;
|
---|
79 | \d+ NewBuildCategories
|
---|
80 |
|
---|
81 | INSERT INTO NewBuildCategories (idBuildCategory, sProduct, sRepository, sBranch, sType, asOsArches)
|
---|
82 | SELECT idBuildCategory, sProduct, 'vbox', sBranch, sType, asOsArches
|
---|
83 | FROM BuildCategories
|
---|
84 | COMMIT;
|
---|
85 |
|
---|
86 | -- Switch the tables.
|
---|
87 | ALTER TABLE BuildCategories RENAME TO OldBuildCategories;
|
---|
88 | ALTER TABLE NewBuildCategories RENAME TO BuildCategories;
|
---|
89 | COMMIT;
|
---|
90 |
|
---|
91 | -- Drop the old table.
|
---|
92 | DROP TABLE OldBuildCategories;
|
---|
93 | COMMIT;
|
---|
94 |
|
---|
95 | -- Restore foreign keys.
|
---|
96 | LOCK TABLE Builds, TestSets;
|
---|
97 | ALTER TABLE Builds ADD FOREIGN KEY (idBuildCategory) REFERENCES BuildCategories(idBuildCategory);
|
---|
98 | ALTER TABLE TestSets ADD FOREIGN KEY (idBuildCategory) REFERENCES BuildCategories(idBuildCategory);
|
---|
99 | COMMIT;
|
---|
100 |
|
---|
101 | \d+ BuildCategories;
|
---|
102 |
|
---|
103 |
|
---|
104 | --
|
---|
105 | -- Create the new VcsRevisions table.
|
---|
106 | --
|
---|
107 | CREATE TABLE VcsRevisions (
|
---|
108 | --- The version control tree name.
|
---|
109 | sRepository TEXT NOT NULL,
|
---|
110 | --- The version control tree revision number.
|
---|
111 | iRevision INTEGER NOT NULL,
|
---|
112 | --- When the revision was created (committed).
|
---|
113 | tsCreated TIMESTAMP WITH TIME ZONE NOT NULL,
|
---|
114 | --- The name of the committer.
|
---|
115 | -- @note Not to be confused with uidAuthor and test manager users.
|
---|
116 | sAuthor TEXT,
|
---|
117 | --- The commit message.
|
---|
118 | sMessage TEXT,
|
---|
119 |
|
---|
120 | UNIQUE (sRepository, iRevision)
|
---|
121 | );
|
---|
122 | COMMIT;
|
---|
123 | \d+ VcsRevisions;
|
---|
124 |
|
---|