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