Edgewall Software

Changes between Initial Version and Version 1 of TracDev/DatabaseSchema/Common


Ignore:
Timestamp:
Mar 11, 2012, 7:06:33 PM (7 years ago)
Author:
Peter Suter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/DatabaseSchema/Common

    v1 v1  
     1[[PageOutline(2)]]
     2
     3= Trac Database Schema: Common
     4
     5Trac stores common authentication, caching, permission, session and system information in the database that is not specific to a certain module.
     6
     7== Table `system`
     8||'''Table'''||'''Key'''||
     9||''system''||''name''||
     10
     11||'''Columns'''||
     12||''name''||
     13||''value''||
     14
     15Stores some system properties.
     16
     17Trac itself only uses this table for managing database upgrades. It initializes this table with the following data during installation or upgrades:
     18
     19||'''name'''||'''value'''||
     20||''database_version''||The (upgraded) DB version||
     21||''initial_database_version''||The DB version||
     22
     23These values can be accessed using `env.get_version()` and `env.get_version(initial=True)` where `env` is an instance of `trac.env.Environment` (e.g. `self.env` in a `Component`.)
     24
     25(In earlier Trac versions, there were additional properties named ''repository_dir'' and ''youngest_rev''. These are now part of the VcCache.)
     26
     27See [browser:trunk/trac/env.py trac.env.Environment]
     28
     29== Table `permission`
     30||'''Table'''||'''Key'''||
     31||''permission''||''username'', ''action''||
     32
     33||'''Columns'''||
     34||''username''||
     35||''action''||
     36       
     37Stores TracPermissions (and TracFineGrainedPermissions).
     38
     39If `action` is ''not all uppercase'', it actually stores a permission group name. (`username` might store a permission group name in both cases.)
     40       
     41This table should be used via the permission cache that can be used to check the permissions of the relevant user (both for performance and correctness reasons, e.g. other permission group providers etc. would be sidestepped otherwise.) That permission cache is for example available as `req.perm` for request handlers, or as `formatter.perm` for wiki macros.
     42
     43During installation Trac initializes this table with some default permissions for the ''anonymous'' user and the ''authenticated'' group.
     44
     45See [browser:trunk/trac/perm.py trac.perm.DefaultPermissionStore]
     46
     47== Table `auth_cookie`
     48||'''Table'''||'''Key'''||
     49||''auth_cookie''||''cookie'', ''ipnr'', ''name''||
     50
     51||'''Columns'''||'''Type'''||'''Notes'''||
     52||''cookie''|| ||Value of the cookie (32 random hex digits)||
     53||''name''|| ||User name authenticated by this cookie||
     54||''ipnr''|| ||IP address of the user||
     55||''time''||`int`||Last time of authentication||
     56
     57Stores authentication credentials of users. The `trac_auth` cookie identifies the entry of a authenticated user in this table.
     58
     59See [browser:trunk/trac/web/auth.py trac.web.auth.LoginModule], TracDev/TracSession
     60
     61== Table `session`
     62||'''Table'''||'''Key'''||
     63||''session''||''sid'', ''authenticated''||
     64
     65||'''Columns'''||'''Type'''||'''Notes'''||
     66||''sid''|| ||Session ID||
     67||''authenticated''||`int`||`1` for authenticated sessions, `0` for anonymous sessions||
     68||''last_visit''||`int`||Time of last visit of this session's user||
     69
     70||'''Indexes'''||
     71||''last_visit''||
     72||''authenticated''||
     73
     74See [browser:trunk/trac/web/session.py trac.web.session], TracDev/TracSession
     75
     76== Table `session_attribute`
     77||'''Table'''||'''Key'''||
     78||''session_attribute''||''sid'', ''authenticated'', ''name''||
     79
     80||'''Columns'''||'''Type'''||'''Notes'''||
     81||''sid''|| ||Session ID||
     82||''authenticated''||`int`||`1` for authenticated sessions, `0` for anonymous sessions||
     83||''name''|| ||Name of some attribute stored for that session||
     84||''value''|| ||Value of that attribute||
     85
     86This table can be managed using the `Session` object, which is usually available as `req.session`.
     87
     88Trac itself uses session attributes to store various configuration settings, e.g.:
     89* [/prefs Preferences]
     90 * `name`, `email`
     91 * `tz`, `dateinfo`, `lc_time`
     92 * `accesskeys`
     93 * `language`
     94 * `pygments_style`
     95* Wiki editing settings
     96 * `wiki_sidebyside`
     97 * `wiki_editrows`
     98* Timeline settings
     99 * `timeline.lastvisit`, `timeline.nextlastvisit`
     100 * `timeline.daysback`
     101 * `timeline.authors`
     102 *`timeline.filter.*`
     103* Ticket settings
     104 * `ticket_comments_order`, `ticket_comments_only`
     105* Ticket Query settings
     106 * `query_href`
     107 * `query_tickets`
     108 * `query_time`
     109 * `query_constraints`
     110* Diff settings
     111 * `diff_style`
     112 * `diff_contextlines`
     113       
     114See [browser:trunk/trac/web/session.py trac.web.session], TracDev/TracSession
     115
     116== Table `cache`
     117||'''Table'''||'''Key'''||
     118||''cache''||''id''||
     119
     120||'''Columns'''||'''Type'''||'''Notes'''||
     121||''id''||`int`||Identifies a certain property to be cached||
     122||''generation''||`int`||Current generation of this cached property||
     123||''key''|| ||Usually the class-qualified name of the cached property||
     124
     125Use the `CacheManager` component e.g. via the `cached_value` decorator to cache values (in process or thread-local memory). This table is used to manage (e.g., correctly invalidate) these caches.
     126
     127See [browser:trunk/trac/cache.py trac.cache], TracDev/CacheManager