Merge lp://staging/~bryce/launchpad/lp-644794-db-foreign-keys into lp://staging/launchpad/db-devel

Proposed by Bryce Harrington
Status: Merged
Approved by: Bryce Harrington
Approved revision: no longer in the source branch.
Merged at revision: 9876
Proposed branch: lp://staging/~bryce/launchpad/lp-644794-db-foreign-keys
Merge into: lp://staging/launchpad/db-devel
Diff against target: 58 lines (+26/-6)
3 files modified
database/schema/comments.sql (+2/-1)
database/schema/patch-2208-19-0.sql (+24/-0)
lib/lp/bugs/model/bugtracker.py (+0/-5)
To merge this branch: bzr merge lp://staging/~bryce/launchpad/lp-644794-db-foreign-keys
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Robert Collins db Pending
Review via email: mp+37543@code.staging.launchpad.net

Commit message

Switch out a link to DistroSourcePackage, in favor of separate links to Distribution and SourcePackage.

Description of the change

This change switches out a link to DistroSourcePackage, in favor of separate links to Distribution and SourcePackage.

I found when trying to hook up to DSP, that the table didn't provide anything. Below is an email from Gavin explaining why it didn't work, and recommending use of Distribution and SourcePackage links instead.

"""
There's no guarantee that a DistributionSourcePackage object is
backed-up by anything in the database. Indeed, until
DistributionSourcePackageInDatabase was added, there was guaranteed to
be nothing at all.

In addition, DistributionSourcePackageInDatabase should be considered
private, only for the use of DistributionSourcePackage. Eventually
they'll merge, but I don't think that can happen just yet (and that's
something that the Soyuz team will manage I guess).

So, as far as I am aware, the normal way to refer to a source package
in a distribution is to store both the distribution and the source
package name. For example, the BugTask table has distribution and
sourcepackagename columns. In Python, you'd then get the Distribution
and the SourcePackageName, then call
distribution.getSourcePackage(sourcepackagename).

Note that the package name is actually a row in SourcePackageName;
although Distribution.getSourcePackage() does accept strings, it will
immediately look it up in SourcePackageName.
"""

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Fine in general.

We need an index. The old column is UNIQUE, so I suspect the new columns need to be UNIQUE too:

ALTER TABLE BugTrackerComponent ADD CONSTRAINT bugtrackercomponent__disto__spn__key
UNIQUE (distribution, source_package_name);

We also should add a constraint ensuring that if distribution is set, source_package_name is also set:

ALTER TABLE BugTrackerComponent ADD CONSTRAINT valid_target
CHECK (distribution IS NULL = source_package_name IS NULL);

You will need to adjust the comments in comments.sql before this can land.

patch-2208-19-0.sql

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: