~launchpad-pqm/launchpad/devel

29 by Canonical.com Patch Queue Manager
Added database schemas and scripts.
1
--
2
-- This will DESTROY your database and create a fresh one
3
--
4
5
/*
6
7
  TODO
8
9
        - re-evalutate some of the "text" field types, they might need to be "bytea"
10
	  unless we can guarantee utf-8
11
        - re-evaluate the relationship table names, see if there isn't a better name for each of them
12
	- add sample data for the schemas
13
	- make sure names are only [a-z][0-9][-.+] and can only start with [a-z]
14
	- present the database as a set of Interfaces
15
16
  CHANGES
17
18
  v0.94:
19
        - rename soyuz.sql to launchpad.sql
20
	- make Schema.extensible DEFAULT false (thanks spiv)
21
  v0.93:
22
        - add a manifest to Sourcepackage and Product, for the mutable HEAD manifest
23
	- add a manifest to CodeRelease
24
	- rename includeas to entrytype in ManifestEntry
25
	- remove "part" from ManifestEntry
26
	- add hints in Manifest table so sourcerer knows how to name patch branches
27
	- fix my brain dead constraints for mutual exlcusivity on branch/changeset specs
28
	- for a ManifestEntry, branch AND changeset can now both be null, to allow for Scott's virtual entries
29
	- add the Packaging table to indicate the relationship between a Product and a Sourcepackage
30
  v0.92:
31
        - make Schema and Label have name, title, description
32
        - added filenames for UpstreamreleaseFile, SourcepackageFile and BinarypackageBuildFile
33
        - linked BinarypackageBuild to DistroRelease instead of DistroArchRelease
34
        - add the Country table for a list of countries
35
	- add the SpokenIn table to link countries and languages
36
        - rename TranslationProject to TranslationEffort
37
        - add iscurrent (boolean) field to the POTFiles table, current POTFiles
38
	    will be displayed in project summary pages.
39
        - add ChangesetFile, ChangesetFilename and ChangesetFileHash tables
40
        - rename Release to CodeRelease (and all dependent tables)
41
        - refactor Processor and ProcessorFamily:
42
	  - the distroarchrelease now has a processorfamily field
43
	  - the binarypackagebuild (deb) now records its processor
44
	- refactor the allocation of binarypackagebuild's (debs) to distroarchrelease's
45
	  - create a new table BinarypackageUpload that stores the packagearchivestatus
46
	  - remove that status from the BinarypackageBuild table
47
	- refactor sourcepackage upload status
48
	  - move changes and urgency to sourcepackagerelease
49
	  - add builddependsindep so sourcepackagerelease
50
51
  v0.91:
52
        - remove Translation_POTFile_Relationship
53
	- ...and replace with a "project" field in POTFile
54
	- add a commenttext field to the POTMsgIDSighting table so we can track comments in POT files too
55
56
  v0.9:
57
         6 July 2004
58
       - first versioned release
59
*/
60
61
/*
62
  DESTROY ALL TABLES
63
*/
64
DROP TABLE SpokenIn CASCADE;
65
DROP TABLE Country CASCADE;
66
DROP TABLE BugMessageSighting CASCADE;
67
DROP TABLE TranslationEffort_POTFile_Relationship CASCADE;
68
DROP TABLE POComment CASCADE;
69
DROP TABLE Branch_Relationship CASCADE;
70
DROP TABLE BugSystem CASCADE;
71
DROP TABLE BugWatch CASCADE;
72
DROP TABLE RosettaPOTranslationSighting CASCADE;
73
DROP TABLE BugAttachment CASCADE;
74
DROP TABLE BugAttachment_Relationship CASCADE;
75
DROP TABLE License CASCADE;
76
DROP TABLE Bug_Relationship CASCADE;
77
DROP TABLE BugMessage CASCADE;
78
DROP TABLE POTranslationSighting CASCADE;
79
DROP TABLE BugRef CASCADE;
80
DROP TABLE Bug CASCADE;
81
DROP TABLE Packaging CASCADE;
82
DROP TABLE SourcepackageReleaseFile CASCADE;
83
DROP TABLE Sourcepackage_Relationship CASCADE;
84
DROP TABLE SourcepackageRelease CASCADE;
85
DROP TABLE CodeReleaseBugStatus CASCADE;
86
DROP TABLE SourcepackageLabel CASCADE;
87
DROP TABLE SourcepackageBugStatus CASCADE;
88
DROP TABLE Bug_Sourcepackage_Relationship CASCADE;
89
DROP TABLE SourcepackageUpload CASCADE;
90
DROP TABLE Sourcepackage CASCADE;
91
DROP TABLE BinarypackageBuildFile CASCADE;
92
DROP TABLE BinarypackageUpload CASCADE;
93
DROP TABLE BinarypackageBuild CASCADE;
94
DROP TABLE Binarypackage CASCADE;
95
DROP TABLE ProductBugStatus CASCADE;
96
DROP TABLE Branch CASCADE;
97
DROP TABLE ArchConfig CASCADE;
98
DROP TABLE ArchConfigEntry CASCADE;
99
DROP TABLE BugActivity CASCADE;
100
DROP TABLE ArchArchiveLocation CASCADE;
101
DROP TABLE POTranslation CASCADE;
102
DROP TABLE BugSystemType CASCADE;
103
DROP TABLE POTSubscription CASCADE;
104
DROP TABLE ChangesetFileHash CASCADE;
105
DROP TABLE ChangesetFile CASCADE;
106
DROP TABLE ChangesetFileName CASCADE;
107
DROP TABLE Changeset CASCADE;
108
DROP TABLE ArchArchive CASCADE;
109
DROP TABLE UpstreamReleaseFile CASCADE;
110
DROP TABLE UpstreamRelease CASCADE;
111
DROP TABLE CodeRelease CASCADE;
112
DROP TABLE CodeRelease_Relationship CASCADE;
113
DROP TABLE POTInheritance CASCADE;
114
DROP TABLE POTMsgIDSighting CASCADE;
115
DROP TABLE Manifest CASCADE;
116
DROP TABLE ProductLabel CASCADE;
117
DROP TABLE Product CASCADE;
118
DROP TABLE POFile CASCADE;
119
DROP TABLE POTFile CASCADE;
120
DROP TABLE Project_Relationship;
121
DROP TABLE POMsgID CASCADE;
122
DROP TABLE Language CASCADE;
123
DROP TABLE BugLabel CASCADE;
124
DROP TABLE TranslationEffort CASCADE;
125
DROP TABLE Project CASCADE;
126
DROP TABLE Project_TranslationEffort_Relationship CASCADE;
127
DROP TABLE Person CASCADE;
128
DROP TABLE EmailAddress CASCADE;
129
DROP TABLE TranslationFilter CASCADE;
130
DROP TABLE BranchLabel CASCADE;
131
DROP TABLE ManifestEntry CASCADE;
132
DROP TABLE GPGKey CASCADE;
133
DROP TABLE ArchUserID CASCADE;
134
DROP TABLE Membership CASCADE;
135
DROP TABLE WikiName CASCADE;
136
DROP TABLE JabberID CASCADE;
137
DROP TABLE IRCID CASCADE;
138
DROP TABLE PersonLabel CASCADE;
139
DROP TABLE TeamParticipation CASCADE;
140
DROP TABLE Schema CASCADE;
141
DROP TABLE Label CASCADE;
142
DROP TABLE Distribution CASCADE;
143
DROP TABLE DistroRelease CASCADE;
144
DROP TABLE DistroArchRelease CASCADE;
145
DROP TABLE ProcessorFamily CASCADE;
146
DROP TABLE Builder CASCADE;
147
DROP TABLE Processor CASCADE;
148
DROP TABLE SoyuzFileHash CASCADE;
149
DROP TABLE SoyuzFile CASCADE;
150
DROP TABLE OSFileInPackage CASCADE;
151
DROP TABLE OSFile;
152
153
154
155
/*
156
  Person
157
  This is a person in the Soyuz system. A Person can also be a
158
  team if the teamowner is not NULL. Note that we will create a
159
  Person entry whenever we see an email address we didn't know
160
  about, or a GPG key we didn't know about... and if we later
161
  link that to a real Soyuz person we will update all the tables
162
  that refer to that temporary person.
163
164
  A Person is one of these automatically created people if it
165
  has a NULL password and is not a team.
166
  
167
  It's created first so that a Schema can have an owner, we'll
168
  then define Schemas and Labels a bit later.
169
*/
170
CREATE TABLE Person (
171
  person                serial PRIMARY KEY,
172
  presentationname      text,
173
  givenname             text,
174
  familyname            text,
175
  password              text,
176
  teamowner             integer REFERENCES Person,
177
  teamdescription       text,
178
  karma                 integer,
179
  karmatimestamp        timestamp
180
);
181
182
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Mark Shuttleworth', 'Mark', 'Shuttleworth' );     -- 1
183
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Dave Miller', 'David', 'Miller' );                -- 2
184
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Colin Watson', 'Colin', 'Watson' );               -- 3
185
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Steve Alexander', 'Steve', 'Alexander' );         -- 4
186
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Scott James Remnant', 'Scott James', 'Remnant' ); -- 5
187
INSERT INTO Person ( presentationname, givenname, familyname ) VALUES ( 'Robert Collins', 'Robert', 'Collins' );           -- 6
188
189
190
/*
191
  REVELATION. THE SOYUZ METADATA
192
*/
193
194
195
/*
196
  Schema
197
  This is the (finger finger) "metadata" (finger finger)
198
  which makes us... muahaha... distinctive... muahaha,
199
  muahahaha, muahahahahahaa....
200
201
  And yes, I'm not yet sure if my database model for this
202
  is on crack. Comments please. MS 24/06/04
203
*/
204
CREATE TABLE Schema (
205
  schema         serial PRIMARY KEY,
206
  name           text NOT NULL,
207
  title          text NOT NULL,
208
  description    text NOT NULL,
209
  owner          integer NOT NULL REFERENCES Person,
210
  extensible     boolean NOT NULL DEFAULT false
211
);
212
213
214
215
/*
216
  Label
217
  The set of labels in all schemas
218
*/
219
CREATE TABLE Label (
220
  label          serial PRIMARY KEY,
221
  schema         integer NOT NULL REFERENCES Schema,
222
  name           text NOT NULL,
223
  title          text NOT NULL,
224
  description    text NOT NULL
225
);
226
227
228
229
230
/*
231
  EmailAddress
232
  A table of email addresses for Soyuz people.
233
*/
234
CREATE TABLE EmailAddress (
235
  emailid     serial PRIMARY KEY,
236
  email       text NOT NULL UNIQUE,
237
  person      integer NOT NULL REFERENCES Person,
238
  label       integer NOT NULL REFERENCES Label
239
);
240
241
242
243
/*
244
  GPGKey
245
  A table of GPGKeys, mapping them to Soyuz users.
246
*/
247
CREATE TABLE GPGKey (
248
  gpgkey      serial PRIMARY KEY,
249
  person      integer NOT NULL REFERENCES Person,
250
  keyid       text NOT NULL UNIQUE,
251
  fingerprint text NOT NULL UNIQUE,
252
  pubkey      text NOT NULL,
253
  revoked     boolean NOT NULL
254
);
255
256
257
258
/*
259
  ArchUserID
260
  A table of Arch user id's
261
*/
262
CREATE TABLE ArchUserID (
263
  person     integer NOT NULL REFERENCES Person,
264
  archuserid text NOT NULL UNIQUE
265
);
266
267
268
269
/*
270
  WikiName
271
  The identity a person uses on one of the Soyuz wiki's.
272
*/
273
CREATE TABLE WikiName (
274
  person     integer NOT NULL REFERENCES Person,
275
  wiki       text NOT NULL,
276
  wikiname   text NOT NULL,
277
  UNIQUE ( wiki, wikiname )
278
);
279
280
281
282
/*
283
  JabberID
284
  A person's Jabber ID on our network.
285
*/
286
CREATE TABLE JabberID (
287
  person      integer NOT NULL REFERENCES Person,
288
  jabberid    text NOT NULL UNIQUE
289
);
290
291
292
293
/*
294
  IrcID
295
  A person's irc nick's.
296
*/
297
CREATE TABLE IRCID (
298
  person       integer NOT NULL REFERENCES Person,
299
  network      text NOT NULL,
300
  nickname     text NOT NULL
301
);
302
303
304
305
306
/*
307
  PersonLabel
308
  A neat way to attache tags to people...
309
*/
310
CREATE TABLE PersonLabel (
311
  person       integer NOT NULL REFERENCES Person,
312
  label        integer NOT NULL REFERENCES Label
313
);
314
315
316
317
/*
318
  Membership
319
  A table of memberships. It's only valid to have a membership
320
  in a team, not a non-team person.
321
*/
322
CREATE TABLE Membership (
323
  person      integer NOT NULL REFERENCES Person,
324
  team        integer NOT NULL REFERENCES Person,
325
  label       integer NOT NULL REFERENCES Label,
326
  status      integer NOT NULL REFERENCES Label,
327
  PRIMARY KEY ( person, team )
328
);
329
330
331
332
/*
333
  TeamParticipation
334
  This is a table which shows all the memberships
335
  of a person. Effectively it collapses team hierarchies
336
  and flattens them to a straight team-person relation.
337
  People are also members of themselves. This allows
338
  us to query against a person entry elsewhere in Soyuz
339
  and quickly find the things a person is an owner of.
340
*/
341
CREATE TABLE TeamParticipation (
342
  team         integer NOT NULL REFERENCES Person,
343
  person       integer NOT NULL REFERENCES Person,
344
  PRIMARY KEY ( team, person )
345
);
346
347
348
349
/*
350
  BUTTRESS. THE ARCH REPOSITORY.
351
  This is the Soyuz subsystem that handles the storing and
352
  cataloguing of all of our Arch branches.
353
*/
354
355
356
357
/*
358
  ArchArchive
359
  A table of all known Arch Archives.
360
*/
361
CREATE TABLE ArchArchive (
362
  archive       serial PRIMARY KEY,
363
  name          text NOT NULL,
364
  title         text NOT NULL,
365
  description   text NOT NULL,
366
  visible       boolean NOT NULL,
367
  owner         integer REFERENCES Person
368
);
369
370
371
372
/*
373
  ArchArchiveLocation
374
  A table of known Arch archive locations.
375
*/
376
CREATE TABLE ArchArchiveLocation (
377
  archive       integer NOT NULL REFERENCES ArchArchive,
378
  archivetype   integer NOT NULL REFERENCES Label, -- the Arch archive type
379
  url           text NOT NULL,
380
  gpgsigned     boolean NOT NULL
381
);
382
383
384
385
/*
386
  Branch
387
  An Arch Branch in the Soyuz system.
388
*/
389
CREATE TABLE Branch (
390
  branch                 serial PRIMARY KEY,
391
  archive                integer NOT NULL REFERENCES ArchArchive,
392
  categorybranchversion  text NOT NULL,
393
  title                  text NOT NULL,
394
  description            text NOT NULL,
395
  visible                boolean NOT NULL,
396
  owner                  integer REFERENCES Person
397
);
398
399
400
/*
401
  Changeset
402
  An Arch changeset.
403
*/
404
CREATE TABLE Changeset (
405
  changeset      serial PRIMARY KEY,
406
  branch         integer NOT NULL REFERENCES Branch,
407
  createdate     timestamp NOT NULL,
408
  logmessage     text NOT NULL,
409
  author         integer REFERENCES Person,
410
  gpgkey         integer REFERENCES GPGKey
411
);
412
413
414
415
/*
416
  ChangesetFileName
417
  A filename in an arch changeset.
418
*/
419
CREATE TABLE ChangesetFileName (
420
  changesetfilename     serial PRIMARY KEY,
421
  filename              text NOT NULL UNIQUE
422
);
423
424
425
426
/*
427
  ChangesetFile
428
  A file in an arch changeset.
429
*/
430
CREATE TABLE ChangesetFile (
431
  changesetfile      serial PRIMARY KEY,
432
  changeset          integer NOT NULL REFERENCES Changeset,
433
  changesetfilename  integer NOT NULL REFERENCES ChangesetFileName,
434
  filecontents       bytea NOT NULL,
435
  filesize           integer NOT NULL,
436
  UNIQUE ( changeset, changesetfilename )
437
);
438
439
440
441
/*
442
  ChangesetFileHash
443
  A cryptographic hash of a changeset file.
444
*/
445
CREATE TABLE ChangesetFileHash (
446
  changesetfile     integer NOT NULL REFERENCES ChangesetFile,
447
  hashalg           integer NOT NULL REFERENCES Label,
448
  hash              bytea NOT NULL
449
);
450
451
452
453
/*
454
  Branch_Relationship
455
  A table of relationships between branches. For example:
456
  "src is a debianization-branch-of dst"
457
  "src is-a-patch-branch-of dst
458
*/
459
CREATE TABLE Branch_Relationship (
460
  src        integer NOT NULL REFERENCES Branch,
461
  dst        integer NOT NULL REFERENCES Branch,
462
  label      integer NOT NULL REFERENCES Label,
463
  PRIMARY KEY ( src, dst )
464
);
465
466
467
468
469
/*
470
  BranchLabel
471
  A table of labels on branches.
472
*/
473
CREATE TABLE BranchLabel (
474
  branch       int NOT NULL REFERENCES Branch,
475
  label        int NOT NULL REFERENCES Label
476
);
477
478
479
480
481
/*
482
  Manifest
483
  A release manifest. This is sort of an Arch config
484
  on steroids. A Manifest is a set of ManifestEntry's
485
*/
486
CREATE TABLE Manifest (
487
  manifest         serial PRIMARY KEY,
488
  creationdate     timestamp NOT NULL,
489
  brancharchive    integer REFERENCES ArchArchive, --
490
  branchcategory   text,                           -- Where to put new patch-branches
491
  branchversion    text                            --
492
);
493
494
495
496
497
/*
498
  ManifestEntry
499
  An entry in a Manifest. each entry specifies either a branch or
500
  a specific changeset (revision) on a branch, as well as how that
501
  piece of code (revision) is brought into the release.
502
*/
503
CREATE TABLE ManifestEntry (
504
  manifest        integer NOT NULL REFERENCES Manifest,
505
  sequence        integer NOT NULL,
506
  branch          integer REFERENCES Branch,
507
  changeset       integer REFERENCES Changeset,
508
  entrytype       integer NOT NULL REFERENCES Label,
509
  path            text NOT NULL,
510
  patchon         integer NOT NULL,
511
  -- sequence must be a positive integer
512
  CHECK ( sequence > 0 ),
513
  -- EITHER branch OR changeset:
514
  CHECK ( NOT ( branch IS NOT NULL AND changeset IS NOT NULL ) ),
515
  -- the "patchon" must be another manifestentry from the same
516
  -- manifest, and a different sequence
517
  -- XXX no idea how to express this constraint, help!
518
  -- the primary key is the combination of manifest and sequence
519
  PRIMARY KEY ( manifest, sequence )
520
);
521
522
523
524
/*
525
  FLOSS. THE OPEN SOURCE WORLD
526
  This is the Soyuz subsystem that models the open source world
527
  of projects and products.
528
*/
529
530
531
/*
532
 The Project table. This stores information about an open
533
 source project, which can be translated or packaged, or
534
 about which bugs can be filed.
535
*/
536
CREATE TABLE Project (
537
    project      serial PRIMARY KEY,
538
    owner        integer NOT NULL REFERENCES Person,
539
    name         text NOT NULL UNIQUE,
540
    title        text NOT NULL,
541
    description  text,
542
    homepage     text
543
    );
544
545
546
/*
547
 The Project_Relationship table. This stores information about
548
 the relationships between open source projects. For example,
549
 the Gnome project aggregates the GnomeMeeting project.
550
*/
551
CREATE TABLE Project_Relationship (
552
  src           integer NOT NULL REFERENCES Project,
553
  dst           integer NOT NULL REFERENCES Project,
554
  relationship  text NOT NULL,
555
  value         text
556
);
557
558
559
560
/*
561
  Product
562
  A table of project products. A product is something that
563
  can be built, or a branch of code that is useful elsewhere, or
564
  a set of docs... some distinct entity. Products can be made
565
  up of other products, but that is not reflected in this
566
  database. For example, Firefax includes Gecko, both are
567
  products.
568
*/
569
CREATE TABLE Product (
570
  product       serial PRIMARY KEY,
571
  project       integer NOT NULL REFERENCES Project,
572
  owner         integer NOT NULL REFERENCES Person,
573
  name          text NOT NULL,
574
  title         text NOT NULL,
575
  description   text NOT NULL,
576
  homepage      text,
577
  manifest      integer REFERENCES Manifest,
578
  UNIQUE ( project, name )
579
);
580
581
582
583
/*
584
  ProductLabel
585
  A label or metadata on a Product.
586
*/
587
CREATE TABLE ProductLabel (
588
  product  integer NOT NULL REFERENCES Product,
589
  label      integer NOT NULL REFERENCES Label,
590
  PRIMARY KEY ( product, label )
591
);
592
593
594
595
/*
596
  UpstreamRelease
597
  A specific tarball release of Upstream.
598
*/
599
CREATE TABLE UpstreamRelease (
600
  upstreamrelease  serial PRIMARY KEY,
601
  product        integer NOT NULL REFERENCES Product,
602
  releasedate      timestamp NOT NULL,
603
  name             text NOT NULL,
604
  gsvname          text,
605
  description      text,
606
  owner            integer REFERENCES Person
607
);
608
609
610
/*
611
   BUTTRESS phase 2
612
*/
613
614
615
/*
616
  ArchConfig
617
  A table to model Arch configs.
618
*/
619
CREATE TABLE ArchConfig (
620
  archconfig       serial PRIMARY KEY,
621
  name             text NOT NULL,
622
  title            text NOT NULL,
623
  description      text NOT NULL,
624
  upstreamrelease  integer REFERENCES UpstreamRelease,
625
  owner            integer REFERENCES Person
626
);
627
628
629
630
/*
631
  ArchConfigEntry
632
  A table to represent the entries in an Arch config. Each
633
  row is a separate entry in the arch config.
634
*/
635
CREATE TABLE ArchConfigEntry (
636
  archconfig    integer NOT NULL REFERENCES ArchConfig,
637
  path          text NOT NULL,
638
  branch        integer REFERENCES Branch,
639
  changeset     integer REFERENCES Changeset,
640
  -- EITHER branch OR changeset:
641
  CHECK ( NOT ( branch IS NULL AND changeset IS NULL ) ),
642
  CHECK ( NOT ( branch IS NOT NULL AND changeset IS NOT NULL ) )
643
);
644
645
646
647
/*
648
  LOGISTIX. THE PACKAGES AND DISTRIBUTION MANAGER.
649
  Nicknamed after UPS (United Parcel Service) this is the
650
  Soyuz subsystem that deals with distribution and packages.
651
*/
652
653
654
655
/*
656
  ProcessorFamily
657
  A family of CPU's, which are all compatible. In other words, code
658
  compiled for any one of these processors will run on any of the
659
  others.
660
*/
661
CREATE TABLE ProcessorFamily (
662
  processorfamily    serial PRIMARY KEY,
663
  name               text NOT NULL UNIQUE,
664
  title              text NOT NULL,
665
  description        text NOT NULL,
666
  owner              integer NOT NULL REFERENCES Person
667
);
668
669
670
671
/*
672
  Processor
673
  This is a table of system architectures. A DistroArchRelease needs
674
  to be one of these.
675
*/
676
CREATE TABLE Processor (
677
  processor          serial PRIMARY KEY,
678
  family             integer NOT NULL REFERENCES ProcessorFamily,
679
  name               text NOT NULL UNIQUE,
680
  title              text NOT NULL,
681
  description        text NOT NULL,
682
  owner              integer NOT NULL REFERENCES Person
683
);
684
685
686
687
/*
688
  Builder
689
  An Ubuntu build daemon.
690
*/
691
CREATE TABLE Builder (
692
  builder            serial PRIMARY KEY,
693
  processor          integer NOT NULL REFERENCES Processor,
694
  fqdn               text NOT NULL,
695
  name               text NOT NULL,
696
  title              text NOT NULL,
697
  description        integer NOT NULL REFERENCES Person,
698
  UNIQUE ( fqdn, name )
699
);
700
701
702
703
/*
704
  Distribution
705
  An open source distribution. Collection of packages, the reason
706
  for Soyuz existence.
707
*/
708
CREATE TABLE Distribution (
709
  distribution     serial PRIMARY KEY,
710
  name             text NOT NULL,
711
  title            text NOT NULL,
712
  description      text NOT NULL,
713
  components       integer NOT NULL REFERENCES Schema,
714
  sections         integer NOT NULL REFERENCES Schema,
715
  owner            integer NOT NULL REFERENCES Person
716
);
717
718
719
720
/*
721
  DistroRelease
722
  These are releases of the various distributions in the system. For
723
  example: warty, hoary, grumpy, woody, potato, slink, sarge, fc1,
724
  fc2.
725
*/
726
CREATE TABLE DistroRelease (
727
  distrorelease   serial PRIMARY KEY,
728
  distribution    integer NOT NULL REFERENCES Distribution,
729
  name            text NOT NULL, -- "warty"
730
  title           text NOT NULL, -- "Ubuntu 4.10 (The Warty Warthog Release)"
731
  description     text NOT NULL,
732
  version         text NOT NULL, -- "4.10"
733
  releasestate    integer NOT NULL REFERENCES Label
734
);
735
736
737
738
739
/*
740
  DistroArchRelease
741
  This is a distrorelease for a particular architecture, for example,
742
  warty-i386.
743
*/
744
CREATE TABLE DistroArchRelease (
745
  distroarchrelease serial PRIMARY KEY,
746
  distrorelease     integer NOT NULL REFERENCES DistroRelease,
747
  processor         integer NOT NULL REFERENCES Processor,
748
  architecturetag   text NOT NULL,
749
  releasestatus     integer NOT NULL REFERENCES Label,
750
  releasedate       timestamp,
751
  owner             integer NOT NULL REFERENCES Person
752
);
753
754
755
756
/*
757
  SoyuzFile
758
  The Soyuz system keeps copies of all the files that are used to make
759
  up a distribution, such as deb's and tarballs and .dsc files and .spec
760
  files and CodeRelease files... these are represented by this table.
761
*/
762
CREATE TABLE SoyuzFile (
763
  soyuzfile        serial PRIMARY KEY,
764
  filename         text NOT NULL,
765
  filesize         integer NOT NULL
766
);
767
768
769
770
/*
771
  SoyuzFileHash
772
  A hash (cryptographic digest) on the file. We can support multiple
773
  different hashes with different algorithms. Initially we'll just 
774
  use SHA1, but if that gets broken we can trivially switch to another
775
  algorithm.
776
777
  The hash is not required to be UNIQUE but Oscar should flag duplicates
778
  for inspection by hand. Note that the combination of filesize and hash
779
  should be unique or there is something very weird going on. Or we just hit
780
  the crypto lottery and found a collision.
781
*/
782
CREATE TABLE SoyuzFileHash (
783
  soyuzfile       integer NOT NULL REFERENCES SoyuzFile,
784
  hashalg         integer NOT NULL REFERENCES Label,
785
  hash            bytea NOT NULL
786
);
787
788
789
790
/*
791
  UpstreamReleaseFile
792
  A file from an Upstream CodeRelease. Usually this would be a tarball.
793
*/
794
CREATE TABLE UpstreamReleaseFile (
795
  upstreamrelease integer NOT NULL REFERENCES UpstreamRelease,
796
  soyuzfile       integer NOT NULL REFERENCES SoyuzFile,
797
  filetype        integer NOT NULL REFERENCES Label,
798
  filename        text NOT NULL
799
);
800
801
802
803
/*
804
  Sourcepackage
805
  A distribution source package. In RedHat or Debian this is the name
806
  of the source package, in Gentoo it's the Ebuild name.
807
*/
808
CREATE TABLE Sourcepackage (
809
  sourcepackage    serial PRIMARY KEY,
810
  maintainer       integer NOT NULL REFERENCES Person,
811
  name             text NOT NULL,
812
  title            text NOT NULL,
813
  description      text NOT NULL,
814
  manifest         integer REFERENCES Manifest
815
);
816
817
818
819
/*
820
  Sourcepackage_Relationship
821
  The relationship between two source packages. For example, if a source
822
  package in Ubuntu is derived from a source package in Debian, we would
823
  reflect that here.
824
*/
825
CREATE TABLE Sourcepackage_Relationship (
826
  src       integer NOT NULL REFERENCES Sourcepackage,
827
  dst       integer NOT NULL REFERENCES Sourcepackage,
828
  label     integer NOT NULL REFERENCES Sourcepackage,
829
  CHECK ( src <> dst )
830
);
831
832
833
834
/*
835
  SourcepackageLabel
836
  A tag or label on a source package.
837
*/
838
CREATE TABLE SourcepackageLabel (
839
  sourcepackage     integer NOT NULL REFERENCES Sourcepackage,
840
  label             integer NOT NULL REFERENCES Label
841
);
842
843
844
845
846
/*
847
  Packaging
848
  This is really the relationship between a Product and a
849
  Sourcepackage. For example, it allows us to say that
850
  the apache2 source package is a packaging of the
851
  httpd Product from the Apache Group.
852
*/
853
CREATE TABLE Packaging (
854
  product         integer NOT NULL REFERENCES Product,
855
  sourcepackage   integer NOT NULL REFERENCES Sourcepackage,
856
  label           integer NOT NULL REFERENCES Label
857
);
858
859
860
861
862
/*
863
  SourcepackageRelease
864
  A SourcepackageRelease is a specific release of a Sourcepackage, which is
865
  associated with one or more distribution releases. So apache2__2.0.48-3 can
866
  be in both ubuntu/warty and debian/sarge.
867
*/
868
CREATE TABLE SourcepackageRelease (
869
  sourcepackagerelease   serial PRIMARY KEY,
870
  sourcepackage          integer NOT NULL REFERENCES Sourcepackage,
871
  srcpackageformat       integer NOT NULL REFERENCES Label,
872
  creator                integer NOT NULL REFERENCES Person,
873
  version                text NOT NULL, -- "2.0.48-3"
874
  dateuploaded           timestamp NOT NULL,
875
  urgency                integer NOT NULL REFERENCES Label,
876
  dscsigningkey          integer REFERENCES GPGKey,
877
  component              integer REFERENCES Label,
878
  changelog              text,
879
  changes                text,
880
  builddepends           text,
881
  builddependsindep      text,
882
  architecturehintlist   text
883
);
884
885
886
887
/*
888
  SourcepackageReleaseFile
889
  A file associated with a sourcepackagerelease. For example, could be
890
  a .dsc file, or an orig.tar.gz, or a diff.gz...
891
*/
892
CREATE TABLE SourcepackageReleaseFile (
893
  sourcepackagerelease  integer NOT NULL REFERENCES SourcepackageRelease,
894
  soyuzfile             integer NOT NULL REFERENCES SoyuzFile,
895
  filetype              integer NOT NULL REFERENCES Label,
896
  filename              text NOT NULL
897
);
898
899
900
901
/*
902
  SourcepackageUpload
903
  This table indicates which sourcepackagereleases are present in a
904
  given distrorelease. It also indicates their status in that release
905
  (for example, whether or not that sourcepackagerelease has been
906
  withdrawn, or is currently published, in that archive).
907
*/
908
CREATE TABLE SourcepackageUpload (
909
  distrorelease          integer NOT NULL REFERENCES DistroRelease,
910
  sourcepackagerelease   integer NOT NULL REFERENCES SourcepackageRelease,
911
  packagereleasestatus   integer NOT NULL REFERENCES Label,
912
  PRIMARY KEY ( distrorelease, sourcepackagerelease )
913
);
914
915
916
917
/*
918
  Binarypackage
919
  This is a binary package... not an actual built package (that
920
  is a BinarypackageBuild) but the concept of that binary package.
921
  It stores the name of the binary package, together with other
922
  details. Note that different distributions might well have
923
  different binary packages with the same name. In fact, a single
924
  distribution might have binary packages with the same name at
925
  different times, that have entirely different source packages
926
  and hence maintainers.
927
*/
928
CREATE TABLE Binarypackage (
929
  binarypackage    serial PRIMARY KEY,
930
  name             text NOT NULL,
931
  title            text NOT NULL,
932
  description      text NOT NULL
933
);
934
935
936
937
938
/*
939
  BinarypackageBuild
940
  This is an actual package, built on a specific architecture,
941
  ready for installation.
942
*/
943
CREATE TABLE BinarypackageBuild (
944
  binarypackagebuild     serial PRIMARY KEY,
945
  sourcepackagerelease   integer NOT NULL REFERENCES SourcepackageRelease,
946
  binarypackage          integer NOT NULL REFERENCES Binarypackage,
947
  processor              integer NOT NULL REFERENCES Processor,
948
  binpackageformat       integer NOT NULL REFERENCES Label,
949
  version                text NOT NULL,
950
  builddate              timestamp NOT NULL,
951
  gpgsigningkey          integer REFERENCES GPGKey,
952
  component              integer REFERENCES Label,
953
  section                integer REFERENCES Label,
954
  priority               integer REFERENCES Label,
955
  shlibdeps              text,
956
  depends                text,
957
  recommends             text,
958
  suggests               text,
959
  conflicts              text,
960
  replaces               text,
961
  provides               text,
962
  essential              boolean,
963
  installedsize          integer
964
);
965
966
967
968
/*
969
  BinarypackageBuildFile
970
  This is a file associated with a built binary package. Could
971
  be a .deb or an rpm, or something similar from a gentoo box.
972
*/
973
CREATE TABLE BinarypackageBuildFile (
974
  binarypackagebuild     integer NOT NULL REFERENCES BinarypackageBuild,
975
  soyuzfile              integer NOT NULL REFERENCES SoyuzFile,
976
  filetype               integer NOT NULL REFERENCES Label,
977
  filename               text NOT NULL
978
);
979
980
981
982
/*
983
  BinarypackageUpload
984
  This table records the status of a binarypackagebuild (deb) in a
985
  distrorelease (woody)
986
*/
987
CREATE TABLE BinarypackageUpload (
988
  binarypackagebuild     integer NOT NULL REFERENCES BinarypackageBuild,
989
  distrorelease          integer NOT NULL REFERENCES DistroRelease,
990
  packagestatus          integer NOT NULL REFERENCES Label
991
);
992
993
994
995
996
/*
997
  LIBRARIAN. TRACKING UPSTREAM AND SOURCE PACKAGE RELEASES.
998
  This section is devoted to data that tracks upstream and distribution
999
  SOURCE PACKAGE releases. So, for example, Apache 2.0.48 is an
1000
  UpstreamRelease. Apache 2.0.48-3 is a Debian SourcepackageRelease.
1001
  We have data tables for both of those, and the CodeRelease table is
1002
  the data that is common to any kind of CodeRelease. This subsystem also
1003
  keeps track of the actual files associated with CodeReleases, such as
1004
  tarballs and deb's and .dsc files and changelog files...
1005
*/
1006
1007
1008
1009
/*
1010
  CodeRelease
1011
  A release of software. Could be an Upstream release or
1012
  a SourcepackageRelease.
1013
*/
1014
CREATE TABLE CodeRelease (
1015
  coderelease          serial PRIMARY KEY,
1016
  upstreamrelease      integer REFERENCES UpstreamRelease,
1017
  sourcepackagerelease integer REFERENCES SourcepackageRelease,
1018
  manifest             integer REFERENCES Manifest,
1019
  CHECK ( NOT ( upstreamrelease IS NULL AND sourcepackagerelease IS NULL ) ),
1020
  CHECK ( NOT ( upstreamrelease IS NOT NULL AND sourcepackagerelease IS NOT NULL ) )
1021
); -- EITHER upstreamrelease OR sourcepackagerelease must not be NULL
1022
1023
1024
1025
/*
1026
  CodeRelease_Relationship
1027
  Maps the relationships between releases (upstream and
1028
  sourcepackage).
1029
*/
1030
CREATE TABLE CodeRelease_Relationship (
1031
  src       integer NOT NULL REFERENCES CodeRelease,
1032
  dst       integer NOT NULL REFERENCES CodeRelease,
1033
  label     integer NOT NULL REFERENCES Label,
1034
  PRIMARY KEY ( src, dst )
1035
);
1036
1037
1038
1039
1040
/*
1041
  OSFile
1042
  This is a file in one of the OS's managed in Soyuz.
1043
*/
1044
CREATE TABLE OSFile (
1045
  osfile    serial PRIMARY KEY,
1046
  path      text NOT NULL UNIQUE
1047
);
1048
1049
1050
1051
/*
1052
  OSFileInPackage
1053
  This table tells us all the files that are in a given binary package
1054
  build. It also includes information about the files, such as their
1055
  unix permissions, and whether or not they are a conf file.
1056
*/
1057
CREATE TABLE OSFileInPackage (
1058
  osfile               integer NOT NULL REFERENCES OSFile,
1059
  binarypackagebuild   integer NOT NULL REFERENCES BinarypackageBuild,
1060
  unixperms            integer NOT NULL,
1061
  conffile             boolean NOT NULL,
1062
  createdby            boolean NOT NULL
1063
);
1064
1065
1066
1067
/*
1068
  ROSETTA. THE TRANSLATION SUPER-PORTAL
1069
  This is the Soyuz subsystem that coordinates and manages
1070
  the translation of open source software and documentation.
1071
*/
1072
1073
1074
1075
/*
1076
  TranslationFilter
1077
  A set of "sunglasses" through which we see translations. We only want
1078
  to see translations that are compatible with this filter in terms
1079
  of licence, review and contribution criteria. This will not be
1080
  implemented in Rosetta v1.0
1081
*/
1082
CREATE TABLE TranslationFilter (
1083
  translationfilter serial PRIMARY KEY,
1084
  owner             integer NOT NULL REFERENCES Person,
1085
  title             text,
1086
  description       text
1087
);
1088
1089
1090
1091
/*
1092
 The TranslationEffort table. Stores information about each active
1093
 translation effort. Note, a translationeffort is an aggregation of
1094
 works. For example, the Gnome Translation Project, which aims to
1095
 translate the PO files for many gnome applications. This is a point
1096
 for the translation team to rally around.
1097
*/
1098
CREATE TABLE TranslationEffort (
1099
  translationeffort     serial PRIMARY KEY,
1100
  owner                 integer NOT NULL REFERENCES Person,
1101
  title                 text NOT NULL,
1102
  description           text NOT NULL,
1103
  translationfilter     integer REFERENCES TranslationFilter
1104
);
1105
1106
1107
1108
1109
/*
1110
  Project_TranslationEffort_Relationship
1111
  Maps the way a translation project is related to an open source
1112
  project.
1113
*/
1114
CREATE TABLE Project_TranslationEffort_Relationship (
1115
  project             integer NOT NULL REFERENCES Project,
1116
  translationeffort   integer NOT NULL REFERENCES TranslationEffort,
1117
  label               integer NOT NULL REFERENCES Label,
1118
  PRIMARY KEY ( project, translationeffort )
1119
);
1120
1121
1122
1123
1124
/*
1125
  POTInheritance
1126
  A handle on an inheritance sequence for POT files.
1127
*/
1128
CREATE TABLE POTInheritance (
1129
  potinheritance        serial PRIMARY KEY,
1130
  title                 text,
1131
  description           text
1132
);
1133
1134
1135
1136
/*
1137
  License
1138
  A license. We need quite a bit more in the long term
1139
  to track licence compatibility etc.
1140
*/
1141
CREATE TABLE License (
1142
  license               serial PRIMARY KEY,
1143
  legalese              text NOT NULL
1144
);
1145
1146
1147
/*
1148
  POTFile
1149
  A PO Template File, which is the first thing that Rosetta will set
1150
  about translating.
1151
*/
1152
CREATE TABLE POTFile (
1153
  potfile               serial PRIMARY KEY,
1154
  project               integer NOT NULL REFERENCES Project,
1155
  branch                integer REFERENCES Branch,
1156
  changeset             integer REFERENCES Changeset,
1157
  name                  text NOT NULL UNIQUE,
1158
  title                 text NOT NULL,
1159
  description           text NOT NULL,
1160
  copyright             text NOT NULL,
1161
  license               integer NOT NULL REFERENCES License,
1162
  datecreated           timestamp NOT NULL,
1163
  path                  text NOT NULL,
1164
  iscurrent             boolean NOT NULL,
1165
  defaultinheritance    integer REFERENCES POTInheritance,
1166
  defaultfilter         integer REFERENCES TranslationFilter,
1167
  owner                 integer REFERENCES Person,
1168
  -- EITHER branch OR changeset:
1169
  CHECK ( NOT ( branch IS NULL AND changeset IS NULL ) ),
1170
  CHECK ( NOT ( branch IS NOT NULL AND changeset IS NOT NULL ) )
1171
);
1172
1173
1174
1175
/*
1176
  POMsgID
1177
  A PO or POT File MessageID
1178
*/
1179
CREATE TABLE POMsgID (
1180
  pomsgid              serial PRIMARY KEY,
1181
  msgid                text UNIQUE
1182
);
1183
1184
1185
1186
/*
1187
  POTranslation
1188
  A PO translation. This is just a piece of text, where the
1189
  "translation" might in fact be the original language.
1190
*/
1191
CREATE TABLE POTranslation (
1192
  potranslation         serial PRIMARY KEY,
1193
  text                  text
1194
);
1195
1196
1197
1198
/*
1199
  Language
1200
  A table of languages, for Rosetta.
1201
*/
1202
CREATE TABLE Language (
1203
  language              serial PRIMARY KEY,
1204
  code                  text NOT NULL UNIQUE,
1205
  englishname           text,
1206
  nativename            text
1207
);
1208
1209
1210
1211
1212
/*
1213
  Country
1214
  A list of countries.
1215
*/
1216
CREATE TABLE Country (
1217
  country             serial PRIMARY KEY,
1218
  iso3166code2        text NOT NULL,
1219
  iso3166code3        text NOT NULL,
1220
  name                text NOT NULL,
1221
  title               text NOT NULL,
1222
  description         text NOT NULL
1223
);
1224
1225
1226
1227
/*
1228
  SpokenIn
1229
  A table linking countries the languages spoken in them.
1230
*/
1231
CREATE TABLE SpokenIn (
1232
  language           integer NOT NULL REFERENCES Language,
1233
  country            integer NOT NULL REFERENCES Country,
1234
  PRIMARY KEY ( language, country )
1235
);
1236
1237
1238
1239
/*
1240
  POFile
1241
  A PO File. This is a language-specific set of translations.
1242
*/
1243
CREATE TABLE POFile (
1244
  pofile               serial PRIMARY KEY,
1245
  potfile              integer NOT NULL REFERENCES POTFile,
1246
  language             integer NOT NULL REFERENCES Language,
1247
  title                text,
1248
  description          text,
1249
  topcomment           text,  -- the comment at the top of the file
1250
  header               text,  -- the contents of the NULL msgstr
1251
  lasttranslator       integer REFERENCES Person,
1252
  license              integer REFERENCES License,
1253
  completeness         integer  -- between 0 and 100
1254
);
1255
1256
1257
1258
/*
1259
  POTMsgIDSighting
1260
  Table that documents the sighting of a particular msgid in a pot file.
1261
*/
1262
CREATE TABLE POTMsgIDSighting (
1263
  potfile             integer NOT NULL REFERENCES POTFile,
1264
  pomsgid             integer NOT NULL REFERENCES POMsgID,
1265
  firstseen           timestamp NOT NULL,
1266
  lastseen            timestamp NOT NULL,
1267
  iscurrent           boolean NOT NULL,
1268
  commenttext         text,
1269
  singular            integer REFERENCES POMsgID, -- if this is not NULL then it's part of a tuple
1270
  PRIMARY KEY ( potfile, pomsgid )
1271
);
1272
1273
1274
1275
/*
1276
  POTranslationSighting
1277
  A sighting of a translation in a PO file IN REVISION CONTROL. This
1278
  is contrasted with a RosettaPOTranslationSighting, which is a
1279
  translation given to us for a potfile/language.
1280
*/
1281
CREATE TABLE POTranslationSighting (
1282
  potranslationsighting serial PRIMARY KEY,
1283
  pofile                integer NOT NULL REFERENCES POFile,
1284
  pomsgid               integer NOT NULL REFERENCES POMsgID,
1285
  potranslation         integer NOT NULL REFERENCES POTranslation,
1286
  license               integer NOT NULL REFERENCES License,
1287
  fuzzy                 boolean NOT NULL,
1288
  rosettaprovided       boolean NOT NULL,
1289
  firstseen             timestamp NOT NULL,
1290
  lastseen              timestamp NOT NULL,
1291
  iscurrent             boolean NOT NULL,
1292
  commenttext           text,
1293
  pluralform            integer,
1294
  CHECK ( pluralform >= 0 )
1295
);
1296
1297
1298
1299
/*
1300
  RosettaPOTranslationSighting
1301
  A record of a translation given to Rosetta through the web, or
1302
  web service, or otherwise.
1303
*/
1304
CREATE TABLE RosettaPOTranslationSighting (
1305
  rosettapotranslation serial PRIMARY KEY,
1306
  person               integer NOT NULL REFERENCES Person,
1307
  potfile              integer NOT NULL REFERENCES POTFile,
1308
  pomsgid              integer NOT NULL REFERENCES POMsgID,
1309
  language             integer NOT NULL REFERENCES Language,
1310
  potranslation        integer NOT NULL REFERENCES POTranslation,
1311
  license              integer NOT NULL REFERENCES License,
1312
  dateprovided         timestamp NOT NULL,
1313
  datetouched          timestamp NOT NULL,
1314
  pluralform           integer,
1315
  CHECK ( pluralform >= 0 )
1316
);
1317
1318
1319
1320
/*
1321
  POComment
1322
  A table of comments provided by translators and the translation
1323
  system (these are extracted from PO files as well as provided to
1324
  us through the web and web services API).
1325
*/
1326
CREATE TABLE POComment (
1327
  pocomment           serial PRIMARY KEY,
1328
  potfile             integer NOT NULL REFERENCES POTFile,
1329
  pomsgid             integer REFERENCES POMsgID,
1330
  language            integer REFERENCES Language,
1331
  potranslation       integer REFERENCES POTranslation,
1332
  commenttext         text NOT NULL,
1333
  date                timestamp NOT NULL,
1334
  person              integer REFERENCES Person
1335
);
1336
1337
1338
1339
1340
/*
1341
  TranslationEffort_POTFile_Relationship
1342
  A translation project incorporates a POTfile that is under translation.
1343
  The inheritance pointer allows this project to specify a custom
1344
  translation inheritance sequence.
1345
*/
1346
CREATE TABLE TranslationEffort_POTFile_Relationship (
1347
  translationeffort integer NOT NULL REFERENCES TranslationEffort ON DELETE CASCADE,
1348
  potfile            integer NOT NULL REFERENCES POTFile,
1349
  potinheritance     integer REFERENCES POTInheritance,
1350
  UNIQUE (translationeffort , potfile)
1351
);
1352
1353
1354
1355
/*
1356
  Project_POTFile_Relationship
1357
  Captures the relationship between a Project and a translated POTFile.
1358
CREATE TABLE Project_POTFile_Relationship (
1359
  project            integer NOT NULL REFERENCES Project,
1360
  potfile            integer NOT NULL REFERENCES POTFile,
1361
  label              integer NOT NULL REFERENCES Label
1362
);
1363
*/
1364
1365
1366
1367
1368
/*
1369
  POTSubscription
1370
  Records the people who have subscribed to a POT File. They can
1371
  subscribe to the POT file and get all the PO files, or just the PO
1372
  files for a specific language.
1373
*/
1374
CREATE TABLE POTSubscription (
1375
  potsubscription      serial PRIMARY KEY,
1376
  person               integer NOT NULL REFERENCES Person,
1377
  language             integer REFERENCES Language,
1378
  notificationinterval interval NOT NULL,
1379
  lastnotified         timestamp,
1380
  potinheritance       integer REFERENCES POTInheritance,
1381
  translationfilter    integer REFERENCES TranslationFilter
1382
);
1383
1384
1385
1386
/*
1387
  BOOGER. THE ISSUE TRACKING SYSTEM.
1388
  This is the Soyuz subsystem that handled bugs and issue
1389
  tracking for all the distributions we know about.
1390
*/
1391
1392
1393
/*
1394
  Bug
1395
  The core bug entry. A Booger.
1396
*/
1397
CREATE TABLE Bug (
1398
  bug                     serial PRIMARY KEY,
1399
  datecreated             timestamp NOT NULL,
1400
  summary                 text NOT NULL,
1401
  description             text NOT NULL,
1402
  owner                   integer NOT NULL,
1403
  duplicateof             integer REFERENCES Bug,
1404
  communityscore          integer NOT NULL,
1405
  communitytimestamp      timestamp NOT NULL,
1406
  activityscore           integer NOT NULL,
1407
  activitytimestamp       timestamp NOT NULL,
1408
  hits                    integer NOT NULL,
1409
  hitstimestamp           timestamp NOT NULL
1410
);
1411
1412
1413
1414
/*
1415
  CodeReleaseBugStatus
1416
  This is a bug status scorecard. It's not a global status for the
1417
  bug, this is usually attached to a release, or a sourcepackage in
1418
  a distro. So these tell you the status of a bug SOMEWHERE. The
1419
  pointer to this tells you which bug, and on what thing (the 
1420
  SOMEWHERE) the status is being described.
1421
*/
1422
CREATE TABLE CodeReleaseBugStatus (
1423
  bug              integer NOT NULL REFERENCES Bug,
1424
  coderelease      integer NOT NULL REFERENCES CodeRelease,
1425
  explicit         boolean NOT NULL,
1426
  bugstatus        integer NOT NULL REFERENCES Label,
1427
  priority         integer NOT NULL REFERENCES Label,
1428
  severity         integer NOT NULL REFERENCES Label,
1429
  reportedby       integer NOT NULL REFERENCES Person,
1430
  verifiedby       integer NOT NULL REFERENCES Person,
1431
  lastmodifiedby   integer NOT NULL REFERENCES Person,
1432
  PRIMARY KEY ( bug, coderelease )
1433
);
1434
1435
1436
1437
/*
1438
  SourcepackageBugStatus
1439
  The status of a bug with regard to a source package. This is different
1440
  to the status on a specific release, because it includes the concept
1441
  of workflow or prognosis ("what we intend to do with this bug") while
1442
  the release bug status is static ("is the bug present or not").
1443
*/
1444
CREATE TABLE SourcepackageBugStatus (
1445
  bug                integer NOT NULL REFERENCES Bug,
1446
  sourcepackage      integer NOT NULL REFERENCES Sourcepackage,
1447
  bugstatus          integer NOT NULL REFERENCES Label,
1448
  binarypackagename  text,
1449
  wontfix            boolean NOT NULL,
1450
  PRIMARY KEY ( bug, sourcepackage )
1451
);
1452
1453
1454
1455
/*
1456
  Bug_Sourcepackage_Relationship
1457
  This is a mapping of the relationship between a bug and a source
1458
  package. Note that there is another similar table, the SourcepackageBugStatus,
1459
  that is dedicated to the status of a bug in a source package. This one is
1460
  a bit more subtle. For example, you might put an intry in this table to
1461
  indicate that a bug "victimises" a source package. In other words, the
1462
  bug itself does not appear in this sourcepackage, but the functionality
1463
  of the sourcepackage is somehow impacted by the bug.
1464
*/
1465
CREATE TABLE Bug_Sourcepackage_Relationship (
1466
  bug                integer NOT NULL REFERENCES Bug,
1467
  sourcepackage      integer NOT NULL REFERENCES Sourcepackage,
1468
  label              integer NOT NULL REFERENCES Label
1469
);
1470
1471
1472
1473
/*
1474
  ProductBugStatus
1475
  The status of a bug with regard to a product. This is different
1476
  to the status on a specific release, because it includes the concept
1477
  of workflow or prognosis ("what we intend to do with this bug") while
1478
  the release bug status is static ("is the bug present or not").
1479
*/
1480
CREATE TABLE ProductBugStatus (
1481
  bug                integer NOT NULL REFERENCES Bug,
1482
  product            integer NOT NULL REFERENCES Sourcepackage,
1483
  bugstatus          integer NOT NULL REFERENCES Label,
1484
  binarypackagename  text,
1485
  wontfix            boolean NOT NULL,
1486
  PRIMARY KEY ( bug, product )
1487
);
1488
1489
1490
1491
/*
1492
  BugActivity
1493
  A log of all the things that have happened to a bug, as Dave wants
1494
  to keep track of it.
1495
*/
1496
CREATE TABLE BugActivity (
1497
  bug           integer NOT NULL REFERENCES Bug,
1498
  activitydate  timestamp NOT NULL,
1499
  person        integer NOT NULL,
1500
  whatchanged   text NOT NULL,
1501
  oldvalue      text NOT NULL,
1502
  newvalue      text NOT NULL,
1503
  message       text NOT NULL
1504
);
1505
-- XXX this does not have a primary key, theory says it needs one!
1506
1507
1508
1509
1510
/*
1511
  BugRef
1512
  A table of external references for a bug, that are NOT remote
1513
  bug system references, except where the remote bug system is
1514
  not supported by the BugWatch table.
1515
*/
1516
CREATE TABLE BugRef (
1517
  bugref      serial PRIMARY KEY,
1518
  bug         integer NOT NULL REFERENCES Bug,
1519
  bugreftype  integer NOT NULL REFERENCES Label,
1520
  data        text NOT NULL,
1521
  description text NOT NULL,
1522
  owner       integer NOT NULL REFERENCES Person
1523
);
1524
1525
1526
1527
/*
1528
  BugSystemType
1529
  This is a table of bug tracking system types. We don't have much
1530
  version granularity (Bugzilla 2.15 is treated the same as Bugzilla 2.17
1531
  unless you create them as two separate bug system types). This table is
1532
  used by the BugSystem table to indicate the type of a remote bug system.
1533
*/
1534
CREATE TABLE BugSystemType (
1535
  bugsystemtype   serial PRIMARY KEY,
1536
  title           text NOT NULL,
1537
  description     text NOT NULL,
1538
  homepage        text,
1539
  product         integer REFERENCES Product, -- A Soyuz Product if it exists
1540
  owner           integer NOT NULL REFERENCES Person -- who knows most about these
1541
);
1542
/*
1543
INSERT INTO BugSystemType VALUES ( 1, "Bugzilla", "Dave Miller's Labour of Love, the Godfather of Open Source project issue tracking.", "http://www.bugzilla.org", NULL, 2 );
1544
INSERT INTO BugSystemType VALUES ( 2, "DebBugs", "The Debian bug tracking system, ugly as sin but fast and productive as a rabbit in high heels.", "http://bugs.debian.org", NULL, 3 );
1545
INSERT INTO BugSystemType VALUES ( 3, "RoundUp", "Python-based open source bug tracking system with an elegant design and reputation for cleanliness and usability.", NULL, 4 );
1546
*/
1547
1548
1549
/*
1550
  BugSystem
1551
  A table of remote bug systems (for example, Debian's DebBugs, and
1552
  Mozilla's Bugzilla, and SourceForge's tracker...). The baseurl is the
1553
  top of the bug system's tree, from which the URL to a given bug
1554
  status can be determined.
1555
*/
1556
CREATE TABLE BugSystem (
1557
  bugsystem        serial PRIMARY KEY,
1558
  bugsystemtype    integer NOT NULL REFERENCES BugSystemType,
1559
  name             text NOT NULL,
1560
  description      text NOT NULL,
1561
  baseurl          text NOT NULL,
1562
  owner            integer NOT NULL REFERENCES Person
1563
);
1564
1565
1566
1567
/*
1568
  BugWatch
1569
  This is a table of bugs in remote bug systems (for example, upstream
1570
  bugzilla's) which we want to monitor for status changes.
1571
*/
1572
CREATE TABLE BugWatch (
1573
  bugwatch         serial PRIMARY KEY,
1574
  bugsystem        integer NOT NULL REFERENCES BugSystem,
1575
  remotebug        text NOT NULL, -- unique identifier of bug in that system
1576
  remotestatus     text NOT NULL, -- textual representation of status
1577
  lastchanged      timestamp NOT NULL,
1578
  lastchecked      timestamp NOT NULL,
1579
  owner            integer NOT NULL REFERENCES Person,
1580
  datecreated      timestamp NOT NULL
1581
);
1582
1583
1584
1585
1586
/*
1587
  BugAttachment
1588
  A table of attachments to bugs. These are typically patches, screenshots,
1589
  mockups, or other documents.
1590
*/
1591
CREATE TABLE BugAttachment (
1592
  bugattachment   serial PRIMARY KEY,
1593
  owner           integer NOT NULL REFERENCES Person,
1594
  content         text NOT NULL,
1595
  title           text NOT NULL,
1596
  description     text NOT NULL,
1597
  mimetype        text,
1598
  replaces        integer REFERENCES BugAttachment
1599
);
1600
1601
1602
1603
/*
1604
  BugAttachment_Relationship
1605
  A link between bug and attachment that carries some type
1606
  of relationship.
1607
*/
1608
CREATE TABLE BugAttachment_Relationship (
1609
  bug            integer NOT NULL REFERENCES Bug,
1610
  bugattachment  integer NOT NULL REFERENCES BugAttachment,
1611
  label          integer NOT NULL REFERENCES Label,
1612
  PRIMARY KEY ( bug, bugattachment )
1613
);
1614
1615
1616
1617
/*
1618
  BugLabel
1619
  Allows us to attache arbitrary metadata to a bug.
1620
*/
1621
CREATE TABLE BugLabel (
1622
  bug       integer NOT NULL REFERENCES Bug,
1623
  label     integer NOT NULL REFERENCES Label,
1624
  PRIMARY KEY ( bug, label )
1625
);
1626
1627
1628
1629
1630
/*
1631
  Bug_Relationship
1632
  The relationship between two bugs, with a label.
1633
*/
1634
CREATE TABLE Bug_Relationship (
1635
  src        integer NOT NULL REFERENCES Bug,
1636
  dst        integer NOT NULL REFERENCES Bug,
1637
  label      integer NOT NULL REFERENCES Label
1638
);
1639
1640
1641
1642
1643
/*
1644
  BugMessage
1645
  A table of messages about bugs. Could be from the web
1646
  forum, or from email, we don't care and treat them both
1647
  equally. A message can apply to multiple forums.
1648
*/
1649
CREATE TABLE BugMessage (
1650
  bugmessage           serial PRIMARY KEY,
1651
  msgdate              timestamp NOT NULL,
1652
  message              text NOT NULL, -- the message or full email with headers
1653
  person               int REFERENCES Person, -- NULL if we don't know it
1654
  senderemail          text, -- NULL if this came through the web
1655
  parent               int REFERENCES BugMessage, -- gives us threading
1656
  distribution         int REFERENCES Distribution,
1657
  rfc822msgid          text
1658
);
1659
1660
1661
1662
/*
1663
  BugMessageSighting
1664
*/
1665
CREATE TABLE BugMessageSighting (
1666
  bug        integer NOT NULL REFERENCES Bug,
1667
  bugmessage integer NOT NULL REFERENCES BugMessage
1668
);
1669
1670
1671
1672