| | @@ -39,12 +39,12 @@ |
| 39 | 39 | ** changes. The aux tables have an arbitrary version number (typically |
| 40 | 40 | ** a date) which can change frequently. When the content schema changes, |
| 41 | 41 | ** we have to execute special procedures to update the schema. When |
| 42 | 42 | ** the aux schema changes, all we need to do is rebuild the database. |
| 43 | 43 | */ |
| 44 | | -#define CONTENT_SCHEMA "1" |
| 45 | | -#define AUX_SCHEMA "2011-02-25 14:52" |
| 44 | +#define CONTENT_SCHEMA "2" |
| 45 | +#define AUX_SCHEMA "2011-04-25 19:50" |
| 46 | 46 | |
| 47 | 47 | #endif /* INTERFACE */ |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | /* |
| | @@ -51,21 +51,25 @@ |
| 51 | 51 | ** The schema for a repository database. |
| 52 | 52 | ** |
| 53 | 53 | ** Schema1[] contains parts of the schema that are fixed and unchanging |
| 54 | 54 | ** across versions. Schema2[] contains parts of the schema that can |
| 55 | 55 | ** change from one version to the next. The information in Schema2[] |
| 56 | | -** can be reconstructed from the information in Schema1[]. |
| 56 | +** is reconstructed from the information in Schema1[] by the "rebuild" |
| 57 | +** operation. |
| 57 | 58 | */ |
| 58 | 59 | const char zRepositorySchema1[] = |
| 59 | 60 | @ -- The BLOB and DELTA tables contain all records held in the repository. |
| 60 | 61 | @ -- |
| 61 | | -@ -- The BLOB.CONTENT column is always compressed using libz. This |
| 62 | +@ -- The BLOB.CONTENT column is always compressed using zlib. This |
| 62 | 63 | @ -- column might hold the full text of the record or it might hold |
| 63 | 64 | @ -- a delta that is able to reconstruct the record from some other |
| 64 | 65 | @ -- record. If BLOB.CONTENT holds a delta, then a DELTA table entry |
| 65 | 66 | @ -- will exist for the record and that entry will point to another |
| 66 | 67 | @ -- entry that holds the source of the delta. Deltas can be chained. |
| 68 | +@ -- |
| 69 | +@ -- The blob and delta tables collectively hold the "global state" of |
| 70 | +@ -- a Fossil repository. |
| 67 | 71 | @ -- |
| 68 | 72 | @ CREATE TABLE blob( |
| 69 | 73 | @ rid INTEGER PRIMARY KEY, -- Record ID |
| 70 | 74 | @ rcvid INTEGER, -- Origin of this record |
| 71 | 75 | @ size INTEGER, -- Size of content. -1 for a phantom. |
| | @@ -77,17 +81,24 @@ |
| 77 | 81 | @ rid INTEGER PRIMARY KEY, -- Record ID |
| 78 | 82 | @ srcid INTEGER NOT NULL REFERENCES blob -- Record holding source document |
| 79 | 83 | @ ); |
| 80 | 84 | @ CREATE INDEX delta_i1 ON delta(srcid); |
| 81 | 85 | @ |
| 86 | +@ ------------------------------------------------------------------------- |
| 87 | +@ -- The BLOB and DELTA tables above hold the "global state" of a Fossil |
| 88 | +@ -- project; the stuff that is normally exchanged during "sync". The |
| 89 | +@ -- "local state" of a repository is contained in the remaining tables of |
| 90 | +@ -- the zRepositorySchema1 string. |
| 91 | +@ ------------------------------------------------------------------------- |
| 92 | +@ |
| 82 | 93 | @ -- Whenever new blobs are received into the repository, an entry |
| 83 | 94 | @ -- in this table records the source of the blob. |
| 84 | 95 | @ -- |
| 85 | 96 | @ CREATE TABLE rcvfrom( |
| 86 | 97 | @ rcvid INTEGER PRIMARY KEY, -- Received-From ID |
| 87 | 98 | @ uid INTEGER REFERENCES user, -- User login |
| 88 | | -@ mtime DATETIME, -- Time or receipt |
| 99 | +@ mtime DATETIME, -- Time of receipt. Julian day. |
| 89 | 100 | @ nonce TEXT UNIQUE, -- Nonce used for login |
| 90 | 101 | @ ipaddr TEXT -- Remote IP address. NULL for direct. |
| 91 | 102 | @ ); |
| 92 | 103 | @ |
| 93 | 104 | @ -- Information about users |
| | @@ -106,19 +117,21 @@ |
| 106 | 117 | @ cap TEXT, -- Capabilities of this user |
| 107 | 118 | @ cookie TEXT, -- WWW login cookie |
| 108 | 119 | @ ipaddr TEXT, -- IP address for which cookie is valid |
| 109 | 120 | @ cexpire DATETIME, -- Time when cookie expires |
| 110 | 121 | @ info TEXT, -- contact information |
| 122 | +@ mtime DATE, -- last change. seconds since 1970 |
| 111 | 123 | @ photo BLOB -- JPEG image of this user |
| 112 | 124 | @ ); |
| 113 | 125 | @ |
| 114 | 126 | @ -- The VAR table holds miscellanous information about the repository. |
| 115 | 127 | @ -- in the form of name-value pairs. |
| 116 | 128 | @ -- |
| 117 | 129 | @ CREATE TABLE config( |
| 118 | 130 | @ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry |
| 119 | 131 | @ value CLOB, -- Content of the named parameter |
| 132 | +@ mtime DATE, -- last modified. seconds since 1970 |
| 120 | 133 | @ CHECK( typeof(name)='text' AND length(name)>=1 ) |
| 121 | 134 | @ ); |
| 122 | 135 | @ |
| 123 | 136 | @ -- Artifacts that should not be processed are identified in the |
| 124 | 137 | @ -- "shun" table. Artifacts that are control-file forgeries or |
| | @@ -128,11 +141,15 @@ |
| 128 | 141 | @ -- |
| 129 | 142 | @ -- Shunned artifacts do not exist in the blob table. Hence they |
| 130 | 143 | @ -- have not artifact ID (rid) and we thus must store their full |
| 131 | 144 | @ -- UUID. |
| 132 | 145 | @ -- |
| 133 | | -@ CREATE TABLE shun(uuid UNIQUE); |
| 146 | +@ CREATE TABLE shun( |
| 147 | +@ uuid UNIQUE, -- UUID of artifact to be shunned. Canonical form |
| 148 | +@ mtime DATE, -- When added. seconds since 1970 |
| 149 | +@ scom TEXT -- Optional text explaining why the shun occurred |
| 150 | +@ ); |
| 134 | 151 | @ |
| 135 | 152 | @ -- Artifacts that should not be pushed are stored in the "private" |
| 136 | 153 | @ -- table. Private artifacts are omitted from the "unclustered" and |
| 137 | 154 | @ -- "unsent" tables. |
| 138 | 155 | @ -- |
| | @@ -140,17 +157,19 @@ |
| 140 | 157 | @ |
| 141 | 158 | @ -- An entry in this table describes a database query that generates a |
| 142 | 159 | @ -- table of tickets. |
| 143 | 160 | @ -- |
| 144 | 161 | @ CREATE TABLE reportfmt( |
| 145 | | -@ rn integer primary key, -- Report number |
| 146 | | -@ owner text, -- Owner of this report format (not used) |
| 147 | | -@ title text, -- Title of this report |
| 148 | | -@ cols text, -- A color-key specification |
| 149 | | -@ sqlcode text -- An SQL SELECT statement for this report |
| 162 | +@ rn INTEGER PRIMARY KEY, -- Report number |
| 163 | +@ owner TEXT, -- Owner of this report format (not used) |
| 164 | +@ title TEXT UNIQUE, -- Title of this report |
| 165 | +@ mtime DATE, -- Last modified. seconds since 1970 |
| 166 | +@ cols TEXT, -- A color-key specification |
| 167 | +@ sqlcode TEXT -- An SQL SELECT statement for this report |
| 150 | 168 | @ ); |
| 151 | | -@ INSERT INTO reportfmt(title,cols,sqlcode) VALUES('All Tickets','#ffffff Key: |
| 169 | +@ INSERT INTO reportfmt(title,mtime,cols,sqlcode) |
| 170 | +@ VALUES('All Tickets',julianday('1970-01-01'),'#ffffff Key: |
| 152 | 171 | @ #f2dcdc Active |
| 153 | 172 | @ #e8e8e8 Review |
| 154 | 173 | @ #cfe8bd Fixed |
| 155 | 174 | @ #bde5d6 Tested |
| 156 | 175 | @ #cacae5 Deferred |
| | @@ -176,12 +195,13 @@ |
| 176 | 195 | @ -- |
| 177 | 196 | @ -- This table contains sensitive information and should not be shared |
| 178 | 197 | @ -- with unauthorized users. |
| 179 | 198 | @ -- |
| 180 | 199 | @ CREATE TABLE concealed( |
| 181 | | -@ hash TEXT PRIMARY KEY, |
| 182 | | -@ content TEXT |
| 200 | +@ hash TEXT PRIMARY KEY, -- The SHA1 hash of content |
| 201 | +@ mtime DATE, -- Time created. Seconds since 1970 |
| 202 | +@ content TEXT -- Content intended to be concealed |
| 183 | 203 | @ ); |
| 184 | 204 | ; |
| 185 | 205 | |
| 186 | 206 | const char zRepositorySchema2[] = |
| 187 | 207 | @ -- Filenames |
| | @@ -214,11 +234,11 @@ |
| 214 | 234 | @ -- |
| 215 | 235 | @ CREATE TABLE plink( |
| 216 | 236 | @ pid INTEGER REFERENCES blob, -- Parent manifest |
| 217 | 237 | @ cid INTEGER REFERENCES blob, -- Child manifest |
| 218 | 238 | @ isprim BOOLEAN, -- pid is the primary parent of cid |
| 219 | | -@ mtime DATETIME, -- the date/time stamp on cid |
| 239 | +@ mtime DATETIME, -- the date/time stamp on cid. Julian day. |
| 220 | 240 | @ UNIQUE(pid, cid) |
| 221 | 241 | @ ); |
| 222 | 242 | @ CREATE INDEX plink_i2 ON plink(cid,pid); |
| 223 | 243 | @ |
| 224 | 244 | @ -- A "leaf" checkin is a checkin that has no children in the same |
| | @@ -232,11 +252,11 @@ |
| 232 | 252 | @ |
| 233 | 253 | @ -- Events used to generate a timeline |
| 234 | 254 | @ -- |
| 235 | 255 | @ CREATE TABLE event( |
| 236 | 256 | @ type TEXT, -- Type of event: 'ci', 'w', 'e', 't' |
| 237 | | -@ mtime DATETIME, -- Date and time when the event occurs |
| 257 | +@ mtime DATETIME, -- Time of occurrence. Julian day. |
| 238 | 258 | @ objid INTEGER PRIMARY KEY, -- Associated record ID |
| 239 | 259 | @ tagid INTEGER, -- Associated ticket or wiki name tag |
| 240 | 260 | @ uid INTEGER REFERENCES user, -- User who caused the event |
| 241 | 261 | @ bgcolor TEXT, -- Color set by 'bgcolor' property |
| 242 | 262 | @ euser TEXT, -- User set by 'user' property |
| | @@ -319,11 +339,11 @@ |
| 319 | 339 | @ tagid INTEGER REFERENCES tag, -- The tag that added or removed |
| 320 | 340 | @ tagtype INTEGER, -- 0:-,cancel 1:+,single 2:*,propagate |
| 321 | 341 | @ srcid INTEGER REFERENCES blob, -- Artifact of tag. 0 for propagated tags |
| 322 | 342 | @ origid INTEGER REFERENCES blob, -- check-in holding propagated tag |
| 323 | 343 | @ value TEXT, -- Value of the tag. Might be NULL. |
| 324 | | -@ mtime TIMESTAMP, -- Time of addition or removal |
| 344 | +@ mtime TIMESTAMP, -- Time of addition or removal. Julian day |
| 325 | 345 | @ rid INTEGER REFERENCE blob, -- Artifact tag is applied to |
| 326 | 346 | @ UNIQUE(rid, tagid) |
| 327 | 347 | @ ); |
| 328 | 348 | @ CREATE INDEX tagxref_i1 ON tagxref(tagid, mtime); |
| 329 | 349 | @ |
| | @@ -334,11 +354,11 @@ |
| 334 | 354 | @ -- |
| 335 | 355 | @ CREATE TABLE backlink( |
| 336 | 356 | @ target TEXT, -- Where the hyperlink points to |
| 337 | 357 | @ srctype INT, -- 0: check-in 1: ticket 2: wiki |
| 338 | 358 | @ srcid INT, -- rid for checkin or wiki. tkt_id for ticket. |
| 339 | | -@ mtime TIMESTAMP, -- time that the hyperlink was added |
| 359 | +@ mtime TIMESTAMP, -- time that the hyperlink was added. Julian day. |
| 340 | 360 | @ UNIQUE(target, srctype, srcid) |
| 341 | 361 | @ ); |
| 342 | 362 | @ CREATE INDEX backlink_src ON backlink(srcid, srctype); |
| 343 | 363 | @ |
| 344 | 364 | @ -- Each attachment is an entry in the following table. Only |
| | @@ -345,11 +365,11 @@ |
| 345 | 365 | @ -- the most recent attachment (identified by the D card) is saved. |
| 346 | 366 | @ -- |
| 347 | 367 | @ CREATE TABLE attachment( |
| 348 | 368 | @ attachid INTEGER PRIMARY KEY, -- Local id for this attachment |
| 349 | 369 | @ isLatest BOOLEAN DEFAULT 0, -- True if this is the one to use |
| 350 | | -@ mtime TIMESTAMP, -- Time when attachment last changed |
| 370 | +@ mtime TIMESTAMP, -- Last changed. Julian day. |
| 351 | 371 | @ src TEXT, -- UUID of the attachment. NULL to delete |
| 352 | 372 | @ target TEXT, -- Object attached to. Wikiname or Tkt UUID |
| 353 | 373 | @ filename TEXT, -- Filename for the attachment |
| 354 | 374 | @ comment TEXT, -- Comment associated with this attachment |
| 355 | 375 | @ user TEXT -- Name of user adding attachment |
| | @@ -443,11 +463,11 @@ |
| 443 | 463 | @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add |
| 444 | 464 | @ deleted BOOLEAN DEFAULT 0, -- True if deleted |
| 445 | 465 | @ isexe BOOLEAN, -- True if file should be executable |
| 446 | 466 | @ rid INTEGER, -- Originally from this repository record |
| 447 | 467 | @ mrid INTEGER, -- Based on this record due to a merge |
| 448 | | -@ mtime INTEGER, -- Modification time of file on disk |
| 468 | +@ mtime INTEGER, -- Mtime of file on disk. sec since 1970 |
| 449 | 469 | @ pathname TEXT, -- Full pathname relative to root |
| 450 | 470 | @ origname TEXT, -- Original pathname. NULL if unchanged |
| 451 | 471 | @ UNIQUE(pathname,vid) |
| 452 | 472 | @ ); |
| 453 | 473 | @ |
| 454 | 474 | |