~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/patch-2208-65-0.sql

  • Committer: Gary Poster
  • Date: 2011-04-27 13:19:36 UTC
  • mto: (7675.1045.298 db-devel)
  • mto: This revision was merged to the branch mainline in revision 12958.
  • Revision ID: gary.poster@canonical.com-20110427131936-l85jpwpx2wvjv3yr
incorporate changes from DB review

Show diffs side-by-side

added added

removed removed

Lines of Context:
311
311
                      duped_values.subscriber));
312
312
 
313
313
 
314
 
 
315
314
-- CREATE CONSTRAINTS ----------------------------------------------------
316
315
 
317
 
 
318
 
ALTER TABLE ONLY StructuralSubscription
319
 
    ADD CONSTRAINT structuralsubscription__product__subscriber__unique
320
 
        UNIQUE (product, subscriber);
321
 
 
322
 
ALTER TABLE ONLY StructuralSubscription
323
 
    ADD CONSTRAINT structuralsubscription__project__subscriber__unique
324
 
        UNIQUE (project, subscriber);
325
 
 
326
 
 
 
316
CREATE UNIQUE INDEX structuralsubscription__product__subscriber__key
 
317
ON StructuralSubscription(product, subscriber) WHERE product IS NOT NULL;
 
318
 
 
319
CREATE UNIQUE INDEX structuralsubscription__project__subscriber__key
 
320
ON StructuralSubscription(project, subscriber) WHERE project IS NOT NULL;
 
321
 
 
322
-- This represents a subscription to a sourcepackage within a distribution.
327
323
CREATE UNIQUE INDEX
328
 
    structuralsubscription__distribution__sourcepackagename__subscriber__unique
329
 
    ON structuralsubscription
330
 
    USING btree (distribution,
331
 
                 (COALESCE(sourcepackagename, (-1))),
332
 
                 subscriber)
333
 
    WHERE ((distribution IS NOT NULL) AND (subscriber IS NOT NULL));
334
 
 
335
 
ALTER TABLE ONLY StructuralSubscription
336
 
    ADD CONSTRAINT structuralsubscription__distroseries__subscriber__unique
337
 
        UNIQUE (distroseries, subscriber);
338
 
 
339
 
ALTER TABLE ONLY StructuralSubscription
340
 
    ADD CONSTRAINT structuralsubscription__milestone__subscriber__unique
341
 
        UNIQUE (milestone, subscriber);
342
 
 
343
 
ALTER TABLE ONLY StructuralSubscription
344
 
    ADD CONSTRAINT structuralsubscription__productseries__subscriber__unique
345
 
        UNIQUE (productseries, subscriber);
346
 
 
347
 
INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);
 
324
    structuralsubscription__distribution__sourcepackagename__subscriber__key
 
325
ON StructuralSubscription(distribution, sourcepackagename, subscriber)
 
326
WHERE distribution IS NOT NULL AND sourcepackagename IS NOT NULL;
 
327
 
 
328
-- This represents a subscription to an entire distribution.  Even though this
 
329
-- kind of distribution subsumes a sourcepackage distrubution (above), the
 
330
-- configuration may be very different, so they are not necessarily redundant.
 
331
CREATE UNIQUE INDEX structuralsubscription__distribution__subscriber__key
 
332
ON StructuralSubscription(distribution, subscriber)
 
333
WHERE distribution IS NOT NULL AND sourcepackagename IS NULL;
 
334
 
 
335
CREATE UNIQUE INDEX structuralsubscription__distroseries__subscriber__key
 
336
ON StructuralSubscription(distroseries, subscriber)
 
337
WHERE distroseries IS NOT NULL;
 
338
 
 
339
-- NB. Currently we can't subscribe to a (distroseries, sourcepackagename)
 
340
-- so no need for the second partial distroseries index like the two
 
341
-- distribution indexes.
 
342
 
 
343
CREATE UNIQUE INDEX structuralsubscription__milestone__subscriber__key
 
344
ON StructuralSubscription(milestone, subscriber)
 
345
WHERE milestone IS NOT NULL;
 
346
 
 
347
CREATE UNIQUE INDEX structuralsubscription__productseries__subscriber__key
 
348
ON StructuralSubscription(productseries, subscriber)
 
349
WHERE productseries IS NOT NULL;
 
350
 
 
351
-- Drop obsolete indexes - the above constraints make them redundant.
 
352
DROP INDEX structuralsubscription__distribution__sourcepackagename__idx;
 
353
DROP INDEX structuralsubscription__distroseries__idx;
 
354
DROP INDEX structuralsubscription__milestone__idx;
 
355
DROP INDEX structuralsubscription__product__idx;
 
356
DROP INDEX structuralsubscription__productseries__idx;
 
357
DROP INDEX structuralsubscription__project__idx;
 
358
 
 
359
INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 65, 0);