~launchpad-pqm/launchpad/devel

7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
1
-- Copyright 2010 Canonical Ltd.  This software is licensed under the
2
-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4
SET client_min_messages=ERROR;
5
6
7
alter table archivepermission drop constraint archivepermission__archive__fk;
8
ALTER TABLE ONLY archivepermission ADD CONSTRAINT archivepermission__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
9
10
alter table build drop constraint build__archive__fk;
11
ALTER TABLE ONLY build ADD CONSTRAINT build__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
12
13
alter table distributionsourcepackagecache drop constraint distributionsourcepackagecache__archive__fk;
14
ALTER TABLE ONLY distributionsourcepackagecache
15
    ADD CONSTRAINT distributionsourcepackagecache__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
16
17
alter table distroseriespackagecache drop constraint distroseriespackagecache__archive__fk;
18
alter table distroseriespackagecache 
19
    add constraint distroseriespackagecache__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
20
21
alter table packageupload drop constraint packageupload__archive__fk;
22
ALTER TABLE ONLY packageupload
23
    ADD CONSTRAINT packageupload__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
24
25
alter table binarypackagepublishinghistory drop constraint securebinarypackagepublishinghistory__archive__fk;
26
ALTER TABLE ONLY binarypackagepublishinghistory
27
    ADD CONSTRAINT securebinarypackagepublishinghistory__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
28
7675.591.4 by Julian Edwards
fix stupid error
29
alter table sourcepackagepublishinghistory drop constraint securesourcepackagepublishinghistory__archive__fk;
7675.591.3 by Julian Edwards
stub's review
30
alter table sourcepackagepublishinghistory ADD CONSTRAINT sourcepackagepublishinghistory__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
31
32
alter table binarypackagerelease drop constraint binarypackagerelease_build_fk;
33
ALTER TABLE ONLY binarypackagerelease
7675.591.3 by Julian Edwards
stub's review
34
    ADD CONSTRAINT binarypackagerelease__build__fk FOREIGN KEY (build) REFERENCES build(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
35
36
alter table packageuploadsource drop constraint packageuploadsource__packageupload__fk;
37
ALTER TABLE ONLY packageuploadsource
38
    ADD CONSTRAINT packageuploadsource__packageupload__fk FOREIGN KEY (packageupload) REFERENCES packageupload(id) on delete cascade;
39
40
alter table packageuploadbuild drop constraint packageuploadbuild_packageupload_fk;
41
ALTER TABLE ONLY packageuploadbuild
7675.591.3 by Julian Edwards
stub's review
42
    ADD CONSTRAINT packageuploadbuild__packageupload__fk FOREIGN KEY (packageupload) REFERENCES packageupload(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
43
44
alter table sourcepackagereleasefile drop constraint "$1";
45
ALTER TABLE ONLY sourcepackagereleasefile
46
    ADD CONSTRAINT "$1" FOREIGN KEY (sourcepackagerelease) REFERENCES sourcepackagerelease(id) on delete cascade;
47
48
alter table binarypackagefile drop constraint binarypackagefile_binarypackagerelease_fk;
49
ALTER TABLE ONLY binarypackagefile
50
    ADD CONSTRAINT binarypackagefile_binarypackagerelease_fk FOREIGN KEY (binarypackagerelease) REFERENCES binarypackagerelease(id) on delete cascade;
51
52
alter table binarypackagereleasedownloadcount drop constraint binarypackagereleasedownloadcount_archive_fkey;
53
alter table binarypackagereleasedownloadcount 
54
    add constraint binarypackagereleasedownloadcount_archive_fkey FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
55
7675.591.2 by Julian Edwards
Fix typos
56
alter table sourcepackagerecipebuild drop constraint sourcepackagerecipebuild_archive_fkey;
57
alter table sourcepackagerecipebuild 
7675.591.3 by Julian Edwards
stub's review
58
    add constraint sourcepackagerecipebuild__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
59
60
alter table archivearch drop constraint archivearch__archive__fk;
61
alter table archivearch 
62
    add constraint archivearch__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
63
64
alter table archiveauthtoken drop constraint archiveauthtoken_archive_fkey;
65
alter table archiveauthtoken 
7675.591.3 by Julian Edwards
stub's review
66
    add constraint archiveauthtoken__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
67
68
alter table archivedependency drop constraint archivedependency_archive_fkey;
69
alter table archivedependency 
7675.591.3 by Julian Edwards
stub's review
70
    add constraint archivedependency__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
71
72
alter table archivedependency drop constraint archivedependency_dependency_fkey;
73
alter table archivedependency add 
7675.591.3 by Julian Edwards
stub's review
74
    constraint archivedependency__dependency__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
75
76
alter table archivesubscriber drop constraint archivesubscriber_archive_fkey;
77
alter table archivesubscriber 
7675.591.3 by Julian Edwards
stub's review
78
    add constraint archivesubscriber__archive__fk FOREIGN KEY (archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
79
80
alter table packagecopyrequest drop constraint packagecopyrequest__sourcearchive__fk;
81
alter table packagecopyrequest 
7675.591.2 by Julian Edwards
Fix typos
82
    add constraint packagecopyrequest__sourcearchive__fk FOREIGN KEY (source_archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
83
84
alter table packagecopyrequest drop constraint packagecopyrequest__targetarchive__fk;
85
alter table packagecopyrequest 
7675.591.2 by Julian Edwards
Fix typos
86
    add constraint packagecopyrequest__targetarchive__fk FOREIGN KEY (target_archive) REFERENCES archive(id) on delete cascade;
7675.591.1 by Julian Edwards
Make PPA deletions cascade through all necessary tables.
87
88
89
-- If the upload_archive is deleted but the SPR was copied to a different
90
-- archive, then we allow this to be null to signify the original archive
91
-- was removed.
92
alter table sourcepackagerelease alter upload_archive drop not null;
93
94
7675.591.3 by Julian Edwards
stub's review
95
INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 41, 0);