VirtualBox

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

Last change on this file since 69448 was 69448, checked in by vboxsync, 7 years ago

testmanager/db: scm updates

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