#
# Table structure for table 'authtrack'
#

CREATE TABLE authtrack (
  authtime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
  uid bigint(20) DEFAULT '0' NOT NULL,
  session varchar(33) DEFAULT '' NOT NULL,
  ip_from varchar(16) DEFAULT '' NOT NULL,
  ip_prox varchar(16) DEFAULT '' NOT NULL,
  referer varchar(40),
  retpath varchar(50),
  useragent varchar(50),
  login varchar(20) DEFAULT '' NOT NULL,
  passwd varchar(20) DEFAULT '' NOT NULL,
  flag tinyint(3),
  KEY authtime (authtime),
  KEY uid (uid),
  KEY session (session),
  KEY login (login)
);

#Table: authtrack
#Field:  authtime - full time of authorization
#Field:  uid - uid of user authorized - 0 if authorization failed and such
#        authorizations are configured to be logged
#Field:  session - session key (i.e. cookie value and key in sessions table)
#Field:  ip_from - ip of request as reported by Apache->connection->remote_ip
#        if no proxying was detected, value from proxy related header fields
#        parsing otherwise
#Field:  ip_prox - if proxying has been detected this filed contains ip as
#        reported by Apache->connection->remote_ip
#Field:  referer - corresponding value from HTTP header
#Field:  retpath - http URI to redirect user's client after processing cycle
#Field:  useragent - corresponding value from HTTP header
#Field:  login - login as supplied for authorization
#Field:  passwd - password as supplied for authorization
#Field:  flag - bitmask which specifies how authorization attempt had ended
#        values are: 1 - was sucessful, 2 - failed
#        look in cgi-bin/Conf.pm for more on the flag values

#
# Table structure for table 'changes'
#

CREATE TABLE changes (
  chid bigint(20) NOT NULL auto_increment,
  opid bigint(20) DEFAULT '0' NOT NULL,
  name varchar(20) DEFAULT '' NOT NULL,
  value varchar(80) DEFAULT '' NOT NULL,
  PRIMARY KEY (chid),
  KEY chindex (chid),
  KEY oindex (opid),
  KEY valindex (value)
);

#
# Table structure for table 'operations'
#

CREATE TABLE operations (
  opid bigint(20) NOT NULL auto_increment,
  optype enum('new','del','mod'),
  opdate datetime,
  from_ip varchar(16) DEFAULT '' NOT NULL,
  prox_ip varchar(16) default null,
  uid bigint(20) DEFAULT '0' NOT NULL,
  PRIMARY KEY (opid),
  KEY opindex (opid),
  KEY uindex (uid)
);

#Following is principal comments to above structure:
#Table: operations
#Field:  opid - id of operation - primary key for operations, crossreferenced 
#        from changes. Each record in changes references one operation via opid.
#        Several changes can reference one opid, thus denoting groupe of changes
#        performed as one operation.
#Field:  optype - type of operation - field describing type of operation. 
#        May be either 'new' (registering user, creating subscription), 
#        'del' (deleting user or subscription), or 
#        'mod' (modifying existing entry).
#Field:  opdate - date of operation
#Field:  from_ip - ip of request as reported by Apache->connection->remote_ip
#        if no proxying was detected, value from proxy related header fields
#        parsing otherwise
#Field:  prox_ip - if proxying has been detected this filed contains ip as
#        reported by Apache->connection->remote_ip
#Field:  uid - portal uid - as got from Session_id cookie via sessions table 
#        of safeguarddb
#
#Table: changes
#Field:  chid - change id - every change in groupe or the only change in 
#        operationhas it's own unique id
#Field:  opid - operation id - look above
#Field:  name - portal parameter name - for example may be 'login', 'passwd', 
#        'zakladki_login' etc.
#Field:  value - new value set by this operation
#

#
# Table structure for table 'lastauth'
#

CREATE TABLE lastauth (
uid bigint(20) NOT NULL default '0',
authtime datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (uid)
);
#Table: lastauth
#Field:  uid - portalwide user id
#Field:  authtime - datetime of last successfull authorization

#
# Table structure for table 'deletedusers'
#

CREATE TABLE deletedusers (
  uid bigint(20) DEFAULT '0' NOT NULL,
  login varchar(40) DEFAULT '' NOT NULL,
  sid bigint(20) NOT NULL default '0',
  deldate datetime,
  reason int(10) DEFAULT '0' NOT NULL,
  PRIMARY KEY (uid,sid),
  KEY login (login)
);
#Table: deletedusers
#Field:  uid - portalwide user id
#Field:  login - user login on project mail.yandex.ru or narod.ru
#Field:  sid - project id (2 = mail.yandex.ru; 4 = narod.ru)
#Field:  deldate - datetime of moving off
#Field:  reason - reason of moving off (number)

#
# Table structure for table 'deletedreason'
#


CREATE TABLE deletedreason (
  number int(10) DEFAULT '0' NOT NULL,
  comment blob,
  PRIMARY KEY (number)
);

#Table: deletedreason
#Field:  number - number of reason
#Field:  comment - text comment to number

