8c4b530084 2008-02-19 mjanssen: ## -*- tcl -*- 8c4b530084 2008-02-19 mjanssen: # # ## ### ##### ######## ############# ##################### 8c4b530084 2008-02-19 mjanssen: ## Copyright (c) 2008 Mark Janssen. 8c4b530084 2008-02-19 mjanssen: # 8c4b530084 2008-02-19 mjanssen: # This software is licensed as described in the file LICENSE, which 8c4b530084 2008-02-19 mjanssen: # you should have received as part of this distribution. 8c4b530084 2008-02-19 mjanssen: # 8c4b530084 2008-02-19 mjanssen: # This software consists of voluntary contributions made by many 8c4b530084 2008-02-19 mjanssen: # individuals. For exact contribution history, see the revision 8c4b530084 2008-02-19 mjanssen: # history and logs, available at http://fossil-scm.hwaci.com/fossil 8c4b530084 2008-02-19 mjanssen: # # ## ### ##### ######## ############# ##################### 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: ## Repository schema's 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: # # ## ### ##### ######## ############# ##################### 8c4b530084 2008-02-19 mjanssen: ## Requirements 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: package require Tcl 8.5 ; # Required runtime. 8c4b530084 2008-02-19 mjanssen: package require snit ; # OO system. 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: package provide vc::fossil::schema 1.0 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: # # ## ### ##### ######## ############# ##################### 8c4b530084 2008-02-19 mjanssen: ## 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: namespace eval ::vc::fossil { 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: snit::type schema { 8c4b530084 2008-02-19 mjanssen: typemethod repo1 {} { 8c4b530084 2008-02-19 mjanssen: return { 8c4b530084 2008-02-19 mjanssen: -- The BLOB and DELTA tables contain all records held in the repository. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: -- The BLOB.CONTENT column is always compressed using libz. This 8c4b530084 2008-02-19 mjanssen: -- column might hold the full text of the record or it might hold 8c4b530084 2008-02-19 mjanssen: -- a delta that is able to reconstruct the record from some other 8c4b530084 2008-02-19 mjanssen: -- record. If BLOB.CONTENT holds a delta, then a DELTA table entry 8c4b530084 2008-02-19 mjanssen: -- will exist for the record and that entry will point to another 8c4b530084 2008-02-19 mjanssen: -- entry that holds the source of the delta. Deltas can be chained. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE blob( 8c4b530084 2008-02-19 mjanssen: rid INTEGER PRIMARY KEY, -- Record ID 8c4b530084 2008-02-19 mjanssen: rcvid INTEGER, -- Origin of this record 8c4b530084 2008-02-19 mjanssen: size INTEGER, -- Size of content. -1 for a phantom. 8c4b530084 2008-02-19 mjanssen: uuid TEXT UNIQUE, -- SHA1 hash of the content 8c4b530084 2008-02-19 mjanssen: content BLOB -- Compressed content of this record 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE TABLE delta( 8c4b530084 2008-02-19 mjanssen: rid INTEGER PRIMARY KEY, -- Record ID 8c4b530084 2008-02-19 mjanssen: srcid INTEGER NOT NULL REFERENCES blob -- Record holding source document 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX delta_i1 ON delta(srcid); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Whenever new blobs are received into the repository, an entry 8c4b530084 2008-02-19 mjanssen: -- in this table records the source of the blob. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE rcvfrom( 8c4b530084 2008-02-19 mjanssen: rcvid INTEGER PRIMARY KEY, -- Received-From ID 8c4b530084 2008-02-19 mjanssen: uid INTEGER REFERENCES user, -- User login 8c4b530084 2008-02-19 mjanssen: mtime DATETIME, -- Time or receipt 8c4b530084 2008-02-19 mjanssen: nonce TEXT UNIQUE, -- Nonce used for login 8c4b530084 2008-02-19 mjanssen: ipaddr TEXT -- Remote IP address. NULL for direct. 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Information about users 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE user( 8c4b530084 2008-02-19 mjanssen: uid INTEGER PRIMARY KEY, -- User ID 8c4b530084 2008-02-19 mjanssen: login TEXT, -- login name of the user 8c4b530084 2008-02-19 mjanssen: pw TEXT, -- password 8c4b530084 2008-02-19 mjanssen: cap TEXT, -- Capabilities of this user 8c4b530084 2008-02-19 mjanssen: cookie TEXT, -- WWW login cookie 8c4b530084 2008-02-19 mjanssen: ipaddr TEXT, -- IP address for which cookie is valid 8c4b530084 2008-02-19 mjanssen: cexpire DATETIME, -- Time when cookie expires 8c4b530084 2008-02-19 mjanssen: info TEXT, -- contact information 8c4b530084 2008-02-19 mjanssen: photo BLOB -- JPEG image of this user 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- The VAR table holds miscellanous information about the repository. 8c4b530084 2008-02-19 mjanssen: -- in the form of name-value pairs. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE config( 8c4b530084 2008-02-19 mjanssen: name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry 8c4b530084 2008-02-19 mjanssen: value CLOB, -- Content of the named parameter 8c4b530084 2008-02-19 mjanssen: CHECK( typeof(name)='text' AND length(name)>=1 ) 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Artifacts that should not be processed are identified in the 8c4b530084 2008-02-19 mjanssen: -- "shun" table. Artifacts that are control-file forgeries or 8c4b530084 2008-02-19 mjanssen: -- spam can be shunned in order to prevent them from contaminating 8c4b530084 2008-02-19 mjanssen: -- the repository. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE shun(uuid UNIQUE); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- An entry in this table describes a database query that generates a 8c4b530084 2008-02-19 mjanssen: -- table of tickets. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE reportfmt( 8c4b530084 2008-02-19 mjanssen: rn integer primary key, -- Report number 8c4b530084 2008-02-19 mjanssen: owner text, -- Owner of this report format (not used) 8c4b530084 2008-02-19 mjanssen: title text, -- Title of this report 8c4b530084 2008-02-19 mjanssen: cols text, -- A color-key specification 8c4b530084 2008-02-19 mjanssen: sqlcode text -- An SQL SELECT statement for this report 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: } 8c4b530084 2008-02-19 mjanssen: } 8c4b530084 2008-02-19 mjanssen: typemethod repo2 {} { 8c4b530084 2008-02-19 mjanssen: return { 8c4b530084 2008-02-19 mjanssen: -- Filenames 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE filename( 8c4b530084 2008-02-19 mjanssen: fnid INTEGER PRIMARY KEY, -- Filename ID 8c4b530084 2008-02-19 mjanssen: name TEXT UNIQUE -- Name of file page 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Linkages between manifests, files created by that manifest, and 8c4b530084 2008-02-19 mjanssen: -- the names of those files. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: -- pid==0 if the file is added by check-in mid. 8c4b530084 2008-02-19 mjanssen: -- fid==0 if the file is removed by check-in mid. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE mlink( 8c4b530084 2008-02-19 mjanssen: mid INTEGER REFERENCES blob, -- Manifest ID where change occurs 8c4b530084 2008-02-19 mjanssen: pid INTEGER REFERENCES blob, -- File ID in parent manifest 8c4b530084 2008-02-19 mjanssen: fid INTEGER REFERENCES blob, -- Changed file ID in this manifest 8c4b530084 2008-02-19 mjanssen: fnid INTEGER REFERENCES filename -- Name of the file 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX mlink_i1 ON mlink(mid); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX mlink_i2 ON mlink(fnid); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX mlink_i3 ON mlink(fid); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX mlink_i4 ON mlink(pid); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Parent/child linkages 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE plink( 8c4b530084 2008-02-19 mjanssen: pid INTEGER REFERENCES blob, -- Parent manifest 8c4b530084 2008-02-19 mjanssen: cid INTEGER REFERENCES blob, -- Child manifest 8c4b530084 2008-02-19 mjanssen: isprim BOOLEAN, -- pid is the primary parent of cid 8c4b530084 2008-02-19 mjanssen: mtime DATETIME, -- the date/time stamp on cid 8c4b530084 2008-02-19 mjanssen: UNIQUE(pid, cid) 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX plink_i2 ON plink(cid); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Events used to generate a timeline 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE event( 8c4b530084 2008-02-19 mjanssen: type TEXT, -- Type of event 8c4b530084 2008-02-19 mjanssen: mtime DATETIME, -- Date and time when the event occurs 8c4b530084 2008-02-19 mjanssen: objid INTEGER PRIMARY KEY, -- Associated record ID 8c4b530084 2008-02-19 mjanssen: uid INTEGER REFERENCES user, -- User who caused the event 8c4b530084 2008-02-19 mjanssen: bgcolor TEXT, -- Color set by 'bgcolor' property 8c4b530084 2008-02-19 mjanssen: brbgcolor TEXT, -- Color set by 'br-bgcolor' property 8c4b530084 2008-02-19 mjanssen: euser TEXT, -- User set by 'user' property 8c4b530084 2008-02-19 mjanssen: user TEXT, -- Name of the user 8c4b530084 2008-02-19 mjanssen: ecomment TEXT, -- Comment set by 'comment' property 8c4b530084 2008-02-19 mjanssen: comment TEXT -- Comment describing the event 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX event_i1 ON event(mtime); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- A record of phantoms. A phantom is a record for which we know the 8c4b530084 2008-02-19 mjanssen: -- UUID but we do not (yet) know the file content. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE phantom( 8c4b530084 2008-02-19 mjanssen: rid INTEGER PRIMARY KEY -- Record ID of the phantom 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Unclustered records. An unclustered record is a record (including 8c4b530084 2008-02-19 mjanssen: -- a cluster records themselves) that is not mentioned by some other 8c4b530084 2008-02-19 mjanssen: -- cluster. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: -- Phantoms are usually included in the unclustered table. A new cluster 8c4b530084 2008-02-19 mjanssen: -- will never be created that contains a phantom. But another repository 8c4b530084 2008-02-19 mjanssen: -- might send us a cluster that contains entries that are phantoms to 8c4b530084 2008-02-19 mjanssen: -- us. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE unclustered( 8c4b530084 2008-02-19 mjanssen: rid INTEGER PRIMARY KEY -- Record ID of the unclustered file 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Records which have never been pushed to another server. This is 8c4b530084 2008-02-19 mjanssen: -- used to reduce push operations to a single HTTP request in the 8c4b530084 2008-02-19 mjanssen: -- common case when one repository only talks to a single server. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE unsent( 8c4b530084 2008-02-19 mjanssen: rid INTEGER PRIMARY KEY -- Record ID of the phantom 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Each baseline or manifest can have one or more tags. A tag 8c4b530084 2008-02-19 mjanssen: -- is defined by a row in the next table. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: -- Wiki pages are tagged with "wiki-NAME" where NAME is the name of 8c4b530084 2008-02-19 mjanssen: -- the wiki page. Tickets changes are tagged with "ticket-UUID" where 8c4b530084 2008-02-19 mjanssen: -- UUID is the indentifier of the ticket. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE tag( 8c4b530084 2008-02-19 mjanssen: tagid INTEGER PRIMARY KEY, -- Numeric tag ID 8c4b530084 2008-02-19 mjanssen: tagname TEXT UNIQUE -- Tag name. 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR 8c4b530084 2008-02-19 mjanssen: INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT 8c4b530084 2008-02-19 mjanssen: INSERT INTO tag VALUES(3, 'user'); -- TAG_USER 8c4b530084 2008-02-19 mjanssen: INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN 8c4b530084 2008-02-19 mjanssen: 8c4b530084 2008-02-19 mjanssen: -- Assignments of tags to baselines. Note that we allow tags to 8c4b530084 2008-02-19 mjanssen: -- have values assigned to them. So we are not really dealing with 8c4b530084 2008-02-19 mjanssen: -- tags here. These are really properties. But we are going to 8c4b530084 2008-02-19 mjanssen: -- keep calling them tags because in many cases the value is ignored. 8c4b530084 2008-02-19 mjanssen: -- 8c4b530084 2008-02-19 mjanssen: CREATE TABLE tagxref( 8c4b530084 2008-02-19 mjanssen: tagid INTEGER REFERENCES tag, -- The tag that added or removed 8c4b530084 2008-02-19 mjanssen: tagtype INTEGER, -- 0:cancel 1:single 2:branch 8c4b530084 2008-02-19 mjanssen: srcid INTEGER REFERENCES blob, -- Origin of the tag. 0 for propagated tags 8c4b530084 2008-02-19 mjanssen: value TEXT, -- Value of the tag. Might be NULL. 8c4b530084 2008-02-19 mjanssen: mtime TIMESTAMP, -- Time of addition or removal 8c4b530084 2008-02-19 mjanssen: rid INTEGER REFERENCE blob, -- Baseline that tag added/removed from 8c4b530084 2008-02-19 mjanssen: UNIQUE(rid, tagid) 8c4b530084 2008-02-19 mjanssen: ); 8c4b530084 2008-02-19 mjanssen: CREATE INDEX tagxref_i1 ON tagxref(tagid, mtime); 8c4b530084 2008-02-19 mjanssen: } 8c4b530084 2008-02-19 mjanssen: } 8c4b530084 2008-02-19 mjanssen: } 8c4b530084 2008-02-19 mjanssen: }