1 | -- $Id: tmdb-r01-builds-1.pgsql 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
2 | --- @file
|
---|
3 | -- VBox Test Manager Database - Changed Builds to be historized.
|
---|
4 | --
|
---|
5 |
|
---|
6 | --
|
---|
7 | -- Copyright (C) 2012-2019 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 | DROP TABLE OldBuilds;
|
---|
29 | DROP TABLE NewBuilds;
|
---|
30 | DROP INDEX BuildsLookupIdx;
|
---|
31 |
|
---|
32 | \set ON_ERROR_STOP 1
|
---|
33 |
|
---|
34 | --
|
---|
35 | -- idBuild won't be unique, so it cannot be used directly as a foreign key
|
---|
36 | -- by TestSets.
|
---|
37 | --
|
---|
38 | ALTER TABLE TestSets
|
---|
39 | DROP CONSTRAINT TestSets_idBuild_fkey;
|
---|
40 | ALTER TABLE TestSets
|
---|
41 | DROP CONSTRAINT TestSets_idBuildTestSuite_fkey;
|
---|
42 |
|
---|
43 |
|
---|
44 | --
|
---|
45 | -- Create the table, filling it with the current Builds content.
|
---|
46 | --
|
---|
47 | CREATE TABLE NewBuilds (
|
---|
48 | idBuild INTEGER DEFAULT NEXTVAL('BuildIdSeq') NOT NULL,
|
---|
49 | tsCreated TIMESTAMP WITH TIME ZONE DEFAULT current_timestamp NOT NULL,
|
---|
50 | tsEffective TIMESTAMP WITH TIME ZONE DEFAULT current_timestamp NOT NULL,
|
---|
51 | tsExpire TIMESTAMP WITH TIME ZONE DEFAULT TIMESTAMP WITH TIME ZONE 'infinity' NOT NULL,
|
---|
52 | uidAuthor INTEGER DEFAULT NULL,
|
---|
53 | idBuildCategory INTEGER REFERENCES BuildCategories(idBuildCategory) NOT NULL,
|
---|
54 | iRevision INTEGER NOT NULL,
|
---|
55 | sVersion TEXT NOT NULL,
|
---|
56 | sLogUrl TEXT,
|
---|
57 | sBinaries TEXT NOT NULL,
|
---|
58 | fBinariesDeleted BOOLEAN DEFAULT FALSE NOT NULL,
|
---|
59 | UNIQUE (idBuild, tsExpire)
|
---|
60 | );
|
---|
61 |
|
---|
62 | INSERT INTO NewBuilds (idBuild, tsCreated, tsEffective, uidAuthor, idBuildCategory, iRevision, sVersion, sLogUrl, sBinaries)
|
---|
63 | SELECT idBuild, tsCreated, tsCreated, uidAuthor, idBuildCategory, iRevision, sVersion, sLogUrl, sBinaries
|
---|
64 | FROM Builds;
|
---|
65 | COMMIT;
|
---|
66 |
|
---|
67 | -- Switch the tables.
|
---|
68 | ALTER TABLE Builds RENAME TO OldBuilds;
|
---|
69 | ALTER TABLE NewBuilds RENAME TO Builds;
|
---|
70 | COMMIT;
|
---|
71 |
|
---|
72 | -- Finally index the table.
|
---|
73 | CREATE INDEX BuildsLookupIdx ON Builds (idBuildCategory, iRevision);
|
---|
74 | COMMIT;
|
---|
75 |
|
---|
76 | DROP TABLE OldBuilds;
|
---|
77 | COMMIT;
|
---|
78 |
|
---|
79 | -- Fix implicit index name.
|
---|
80 | ALTER INDEX newbuilds_idbuild_tsexpire_key RENAME TO builds_idbuild_tsexpire_key;
|
---|
81 |
|
---|