VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/db/tmdb-r16-testcaseargs-1-testresultfailures-1.pgsql

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1-- $Id: tmdb-r16-testcaseargs-1-testresultfailures-1.pgsql 106061 2024-09-16 14:03:52Z vboxsync $
2--- @file
3-- VBox Test Manager Database - Adds sName to TestCaseArgs, idTestSet
4-- to TestResultFailures and add some indexes to the latter as well.
5--
6
7--
8-- Copyright (C) 2013-2024 Oracle and/or its affiliates.
9--
10-- This file is part of VirtualBox base platform packages, as
11-- available from https://www.virtualbox.org.
12--
13-- This program is free software; you can redistribute it and/or
14-- modify it under the terms of the GNU General Public License
15-- as published by the Free Software Foundation, in version 3 of the
16-- License.
17--
18-- This program is distributed in the hope that it will be useful, but
19-- WITHOUT ANY WARRANTY; without even the implied warranty of
20-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21-- General Public License for more details.
22--
23-- You should have received a copy of the GNU General Public License
24-- along with this program; if not, see <https://www.gnu.org/licenses>.
25--
26-- The contents of this file may alternatively be used under the terms
27-- of the Common Development and Distribution License Version 1.0
28-- (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29-- in the VirtualBox distribution, in which case the provisions of the
30-- CDDL are applicable instead of those of the GPL.
31--
32-- You may elect to license modified versions of this file under the
33-- terms and conditions of either the GPL or the CDDL or both.
34--
35-- SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36--
37
38
39DROP TABLE OldTestCaseArgs;
40DROP TABLE NewTestCaseArgs;
41
42
43\set ON_ERROR_STOP 1
44\set AUTOCOMMIT 0
45
46LOCK TABLE TestBoxStatuses IN ACCESS EXCLUSIVE MODE;
47LOCK TABLE TestSets IN ACCESS EXCLUSIVE MODE;
48LOCK TABLE TestCaseArgs IN ACCESS EXCLUSIVE MODE;
49LOCK TABLE TestResultFailures IN ACCESS EXCLUSIVE MODE;
50
51--
52-- TestCaseArgs is simple and we can use ALTER TABLE for a change.
53--
54\d TestCaseArgs;
55ALTER TABLE TestCaseArgs ADD COLUMN sSubName text DEFAULT NULL;
56\d TestCaseArgs;
57
58
59--
60-- Rename the original table, drop constrains and foreign key references so we
61-- get the right name automatic when creating the new one.
62--
63\d TestResultFailures;
64ALTER TABLE TestResultFailures DROP CONSTRAINT idTestResultFk;
65ALTER TABLE TestResultFailures RENAME TO OldTestResultFailures;
66
67DROP INDEX IF EXISTS TestResultFailureIdx;
68DROP INDEX IF EXISTS TestResultFailureIdx2;
69DROP INDEX IF EXISTS TestResultFailureIdx3;
70
71
72CREATE TABLE TestResultFailures (
73 --- The test result we're disucssing.
74 -- @note The foreign key is declared after TestResults (further down).
75 idTestResult INTEGER NOT NULL,
76 --- When this row starts taking effect (inclusive).
77 tsEffective TIMESTAMP WITH TIME ZONE DEFAULT current_timestamp NOT NULL,
78 --- When this row stops being tsEffective (exclusive).
79 tsExpire TIMESTAMP WITH TIME ZONE DEFAULT TIMESTAMP WITH TIME ZONE 'infinity' NOT NULL,
80 --- The user id of the one who created/modified this entry.
81 -- Non-unique foreign key: Users(uid)
82 uidAuthor INTEGER NOT NULL,
83 --- The testsest this result is a part of.
84 -- This is mainly an aid for bypassing the enormous TestResults table.
85 -- Note! This is a foreign key, but we have to add it after TestSets has
86 -- been created, see further down.
87 idTestSet INTEGER NOT NULL,
88
89 --- The suggested failure reason.
90 -- Non-unique foreign key: FailureReasons(idFailureReason)
91 idFailureReason INTEGER NOT NULL,
92 --- Optional comment.
93 sComment text DEFAULT NULL,
94
95 PRIMARY KEY (idTestResult, tsExpire)
96);
97
98INSERT INTO TestResultFailures ( idTestResult, tsEffective, tsExpire, uidAuthor, idTestSet, idFailureReason, sComment )
99 SELECT o.idTestResult, o.tsEffective, o.tsExpire, o.uidAuthor, tr.idTestSet, o.idFailureReason, sComment
100 FROM OldTestResultFailures o,
101 TestResults tr
102 WHERE o.idTestResult = tr.idTestResult;
103
104-- Add unique constraint to TestResult for our new foreign key.
105ALTER TABLE TestResults ADD CONSTRAINT TestResults_idTestResult_idTestSet_key UNIQUE (idTestResult, idTestSet);
106
107-- Restore foreign key.
108ALTER TABLE TestResultFailures ADD CONSTRAINT TestResultFailures_idTestResult_idTestSet_fkey
109 FOREIGN KEY (idTestResult, idTestSet) REFERENCES TestResults(idTestResult, idTestSet) MATCH FULL;
110
111-- Add new indexes.
112CREATE INDEX TestResultFailureIdx ON TestResultFailures (idTestSet, tsExpire DESC, tsEffective ASC);
113CREATE INDEX TestResultFailureIdx2 ON TestResultFailures (idTestResult, tsExpire DESC, tsEffective ASC);
114CREATE INDEX TestResultFailureIdx3 ON TestResultFailures (idFailureReason, idTestResult, tsExpire DESC, tsEffective ASC);
115
116-- Drop the old table.
117DROP TABLE OldTestResultFailures;
118
119COMMIT;
120
121\d TestResultFailures;
122
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette