Merge ~cjwatson/launchpad:db-built-using into launchpad:db-devel

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 43656977ae6adc4319c2f4617ff05e311f7963fe
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:db-built-using
Merge into: launchpad:db-devel
Diff against target: 31 lines (+25/-0)
1 file modified
database/schema/patch-2210-13-0.sql (+25/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Review via email: mp+381036@code.launchpad.net

Commit message

Add BinarySourceReference table

Description of the change

This will be used to implement the Built-Using field in archives.

The grants for ArchiveDependency are needed because anything that creates BinarySourceReference rows from package relationship fields ("source-package-name (= version)") needs to work out which SPR was actually used by the build. It's not clear how to do this completely unambiguously, but we can derive a good approximation by trying the build's archive dependencies in order. To support this, anything that creates BinarySourceReferences needs to be able to read ArchiveDependency.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

The permission changes (and corresponding commit message paragraph) feel like they would have fit better in the model branch, but looks good anyway.

review: Approve (db)
Revision history for this message
Colin Watson (cjwatson) wrote :

OK, I've moved the permission changes over to the model branch, adjusted its commit message, and rebased that stack.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2210-13-0.sql b/database/schema/patch-2210-13-0.sql
2new file mode 100644
3index 0000000..0889468
4--- /dev/null
5+++ b/database/schema/patch-2210-13-0.sql
6@@ -0,0 +1,25 @@
7+-- Copyright 2020 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+CREATE TABLE BinarySourceReference (
13+ id serial PRIMARY KEY,
14+ binary_package_release integer NOT NULL REFERENCES binarypackagerelease,
15+ source_package_release integer NOT NULL REFERENCES sourcepackagerelease,
16+ reference_type integer NOT NULL
17+);
18+
19+COMMENT ON TABLE BinarySourceReference IS 'A reference from a binary package release to a source package release.';
20+COMMENT ON COLUMN BinarySourceReference.binary_package_release IS 'The referencing binary package release.';
21+COMMENT ON COLUMN BinarySourceReference.source_package_release IS 'The referenced source package release.';
22+COMMENT ON COLUMN BinarySourceReference.reference_type IS 'The type of the reference.';
23+
24+CREATE INDEX binarysourcereference__bpr__type__idx
25+ ON BinarySourceReference (binary_package_release, reference_type);
26+CREATE INDEX binarysourcereference__spr__type__idx
27+ ON BinarySourceReference (source_package_release, reference_type);
28+CREATE UNIQUE INDEX binarysourcereference__bpr__spr__type__key
29+ ON BinarySourceReference (binary_package_release, source_package_release, reference_type);
30+
31+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 13, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: