Edgewall Software

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

Mar 11, 2012, 7:06:33 PM (10 years ago)
Peter Suter


  • TracDev/DatabaseSchema/Common

    v1 v1  
     3= Trac Database Schema: Common
     5Trac stores common authentication, caching, permission, session and system information in the database that is not specific to a certain module.
     7== Table `system`
     15Stores some system properties.
     17Trac itself only uses this table for managing database upgrades. It initializes this table with the following data during installation or upgrades:
     20||''database_version''||The (upgraded) DB version||
     21||''initial_database_version''||The DB version||
     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`.)
     25(In earlier Trac versions, there were additional properties named ''repository_dir'' and ''youngest_rev''. These are now part of the VcCache.)
     27See [browser:trunk/trac/env.py trac.env.Environment]
     29== Table `permission`
     31||''permission''||''username'', ''action''||
     37Stores TracPermissions (and TracFineGrainedPermissions).
     39If `action` is ''not all uppercase'', it actually stores a permission group name. (`username` might store a permission group name in both cases.)
     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.
     43During installation Trac initializes this table with some default permissions for the ''anonymous'' user and the ''authenticated'' group.
     45See [browser:trunk/trac/perm.py trac.perm.DefaultPermissionStore]
     47== Table `auth_cookie`
     49||''auth_cookie''||''cookie'', ''ipnr'', ''name''||
     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||
     57Stores authentication credentials of users. The `trac_auth` cookie identifies the entry of a authenticated user in this table.
     59See [browser:trunk/trac/web/auth.py trac.web.auth.LoginModule], TracDev/TracSession
     61== Table `session`
     63||''session''||''sid'', ''authenticated''||
     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||
     74See [browser:trunk/trac/web/session.py trac.web.session], TracDev/TracSession
     76== Table `session_attribute`
     78||''session_attribute''||''sid'', ''authenticated'', ''name''||
     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||
     86This table can be managed using the `Session` object, which is usually available as `req.session`.
     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`
     114See [browser:trunk/trac/web/session.py trac.web.session], TracDev/TracSession
     116== Table `cache`
     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||
     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.
     127See [browser:trunk/trac/cache.py trac.cache], TracDev/CacheManager