CREATE TABLE PermissionConfig (
  PermissionConfigId int(11) NOT NULL auto_increment,
  PermissionName varchar(30) NOT NULL default '',
  Description varchar(255) NOT NULL default '',
  ErrorMessage varchar(255) NOT NULL default '',
  ModuleId varchar(20) NOT NULL default '0',
  PRIMARY KEY  (PermissionConfigId),
  KEY PermissionName (PermissionName)
);

CREATE TABLE Permissions (
  PermissionId int(11) NOT NULL auto_increment,
  Permission varchar(255) NOT NULL default '',
  GroupId int(11) default '0',
  PermissionValue int(11) NOT NULL default '0',
  `Type` tinyint(4) NOT NULL default '0',
  CatId int(11) NOT NULL default '0',
  PRIMARY KEY  (PermissionId),
  UNIQUE KEY PermIndex (Permission,GroupId,CatId,`Type`)
);

CREATE TABLE CustomField (
  CustomFieldId int(11) NOT NULL auto_increment,
  `Type` int(11) NOT NULL default '0',
  FieldName varchar(255) NOT NULL default '',
  FieldLabel varchar(40) default NULL,
  MultiLingual tinyint(3) unsigned NOT NULL default '1',
  Heading varchar(60) default NULL,
  Prompt varchar(60) default NULL,
  ElementType varchar(50) NOT NULL default '',
  ValueList text,
  DefaultValue varchar(255) NOT NULL default '',
  DisplayOrder int(11) NOT NULL default '0',
  OnGeneralTab tinyint(4) NOT NULL default '0',
  IsSystem tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (CustomFieldId),
  KEY `Type` (`Type`),
  KEY MultiLingual (MultiLingual),
  KEY DisplayOrder (DisplayOrder),
  KEY OnGeneralTab (OnGeneralTab),
  KEY IsSystem (IsSystem),
  KEY DefaultValue (DefaultValue)
);

CREATE TABLE ConfigurationAdmin (
  VariableName varchar(80) NOT NULL default '',
  heading varchar(255) default NULL,
  prompt varchar(255) default NULL,
  element_type varchar(20) NOT NULL default '',
  validation varchar(255) default NULL,
  ValueList text,
  DisplayOrder double NOT NULL default '0',
  GroupDisplayOrder double NOT NULL default '0',
  Install int(11) NOT NULL default '1',
  PRIMARY KEY  (VariableName),
  KEY DisplayOrder (DisplayOrder),
  KEY GroupDisplayOrder (GroupDisplayOrder),
  KEY Install (Install)
);

CREATE TABLE ConfigurationValues (
  VariableId int(11) NOT NULL auto_increment,
  VariableName varchar(255) NOT NULL default '',
  VariableValue text,
  ModuleOwner varchar(20) default 'In-Portal',
  Section varchar(255) NOT NULL default '',
  PRIMARY KEY  (VariableId),
  UNIQUE KEY VariableName (VariableName)
);

CREATE TABLE EmailMessage (
  EmailMessageId int(10) NOT NULL auto_increment,
  Template longtext,
  MessageType enum('html','text') NOT NULL default 'text',
  LanguageId int(11) NOT NULL default '0',
  EventId int(11) NOT NULL default '0',
  `Subject` text,
  PRIMARY KEY  (EmailMessageId)
);

CREATE TABLE EmailQueue (
  EmailQueueId int(10) unsigned NOT NULL auto_increment,
  ToEmail varchar(255) NOT NULL default '',
  `Subject` varchar(255) NOT NULL default '',
  MessageHeaders text,
  MessageBody longtext,
  Queued int(10) unsigned NOT NULL default '0',
  SendRetries int(10) unsigned NOT NULL default '0',
  LastSendRetry int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (EmailQueueId),
  KEY LastSendRetry (LastSendRetry),
  KEY SendRetries (SendRetries)
);

CREATE TABLE EmailSubscribers (
  EmailMessageId int(11) NOT NULL default '0',
  PortalUserId int(11) NOT NULL default '0',
  KEY EmailMessageId (EmailMessageId),
  KEY PortalUserId (PortalUserId)
);

CREATE TABLE Events (
  EventId int(11) NOT NULL auto_increment,
  Event varchar(40) NOT NULL default '',
  ReplacementTags text,
  Enabled int(11) NOT NULL default '1',
  FromUserId int(11) NOT NULL default '-1',
  Module varchar(40) NOT NULL default '',
  Description varchar(255) NOT NULL default '',
  Type int(11) NOT NULL default '0',
  PRIMARY KEY  (EventId),
  KEY Type (Type),
  KEY Enabled (Enabled)
);

CREATE TABLE IdGenerator (
  lastid int(11) default NULL
);

CREATE TABLE Language (
  LanguageId int(11) NOT NULL auto_increment,
  PackName varchar(40) NOT NULL default '',
  LocalName varchar(40) NOT NULL default '',
  Enabled int(11) NOT NULL default '1',
  PrimaryLang int(11) NOT NULL default '0',
  AdminInterfaceLang tinyint(3) unsigned NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  IconURL varchar(255) default NULL,
  DateFormat varchar(50) NOT NULL default '',
  TimeFormat varchar(50) NOT NULL default '',
  InputDateFormat varchar(50) NOT NULL default 'm/d/Y',
  InputTimeFormat varchar(50) NOT NULL default 'g:i:s A',
  DecimalPoint VARCHAR(10) NOT NULL DEFAULT '',
  ThousandSep VARCHAR(10) NOT NULL DEFAULT '',
  `Charset` varchar(20) NOT NULL default '',
  UnitSystem tinyint(4) NOT NULL default '1',
  FilenameReplacements TEXT NULL,
  `Locale` varchar(10) NOT NULL default 'en-US',
  PRIMARY KEY  (LanguageId),
  KEY Enabled (Enabled),
  KEY PrimaryLang (PrimaryLang),
  KEY AdminInterfaceLang (AdminInterfaceLang),
  KEY Priority (Priority)
);

CREATE TABLE Modules (
  `Name` varchar(255) NOT NULL default '',
  Path varchar(255) NOT NULL default '',
  `Var` VARCHAR(100) NOT NULL DEFAULT '',
  Version varchar(10) NOT NULL default '0.0.0',
  Loaded tinyint(4) NOT NULL default '1',
  LoadOrder tinyint(4) NOT NULL default '0',
  TemplatePath varchar(255) NOT NULL default '',
  RootCat int(11) NOT NULL default '0',
  BuildDate int(10) unsigned default NULL,
  PRIMARY KEY  (`Name`),
  KEY Loaded (Loaded),
  KEY LoadOrder (LoadOrder)
);

CREATE TABLE PersistantSessionData (
  VariableId bigint(20) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  VariableName varchar(255) NOT NULL default '',
  VariableValue text NOT NULL,
  PRIMARY KEY (VariableId),
  KEY UserId (PortalUserId),
  KEY VariableName (VariableName)
);

CREATE TABLE Phrase (
  Phrase varchar(255) NOT NULL default '',
  Translation text NOT NULL,
  PhraseType int(11) NOT NULL default '0',
  PhraseId int(11) NOT NULL auto_increment,
  LanguageId int(11) NOT NULL default '0',
  LastChanged int(10) unsigned NOT NULL default '0',
  LastChangeIP varchar(15) NOT NULL default '',
  Module VARCHAR(30) NOT NULL DEFAULT 'In-Portal',
  PRIMARY KEY  (PhraseId),
  KEY LanguageId (LanguageId),
  INDEX Phrase_Index (Phrase)
);

CREATE TABLE PhraseCache (
  Template varchar(40) NOT NULL default '',
  PhraseList text NOT NULL,
  CacheDate int(11) NOT NULL default '0',
  ThemeId int(11) NOT NULL default '0',
  StylesheetId int(10) unsigned NOT NULL default '0',
  ConfigVariables text,
  PRIMARY KEY  (Template),
  KEY CacheDate (CacheDate),
  KEY ThemeId (ThemeId),
  KEY StylesheetId (StylesheetId)
);

CREATE TABLE PortalGroup (
  GroupId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Description varchar(255) default NULL,
  CreatedOn int(10) unsigned default NULL,
  System tinyint(4) NOT NULL default '0',
  Personal tinyint(4) NOT NULL default '0',
  Enabled tinyint(4) NOT NULL default '1',
  ResourceId int(11) NOT NULL default '0',
  FrontRegistration tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (GroupId),
  UNIQUE KEY Name (Name),
  UNIQUE KEY ResourceId (ResourceId),
  KEY Personal (Personal),
  KEY Enabled (Enabled),
  KEY CreatedOn (CreatedOn)
);

CREATE TABLE PortalUser (
  PortalUserId int(11) NOT NULL auto_increment,
  Login varchar(255) default NULL,
  `Password` VARCHAR(255) NULL DEFAULT 'd41d8cd98f00b204e9800998ecf8427e',
  FirstName VARCHAR(255) NOT NULL DEFAULT '',
  LastName VARCHAR(255) NOT NULL DEFAULT '',
  Company varchar(255) NOT NULL default '',
  Email varchar(255) NOT NULL default '',
  CreatedOn INT DEFAULT NULL,
  Phone varchar(20) default NULL,
  Fax varchar(255) NOT NULL default '',
  Street varchar(255) default NULL,
  Street2 varchar(255) NOT NULL default '',
  City varchar(20) default NULL,
  State varchar(20) NOT NULL default '',
  Zip varchar(20) default NULL,
  Country varchar(20) NOT NULL default '',
  ResourceId int(11) NOT NULL default '0',
  `Status` tinyint(4) NOT NULL default '2',
  Modified int(11) NOT NULL default '0',
  dob INT(11) NULL DEFAULT NULL,
  tz int(11) default NULL,
  ip varchar(20) default NULL,
  IsBanned tinyint(1) NOT NULL default '0',
  PassResetTime INT(11) UNSIGNED NULL DEFAULT NULL,
  PwResetConfirm varchar(255) default NULL,
  PwRequestTime INT(11) UNSIGNED NULL DEFAULT NULL,
  MinPwResetDelay int(11) NOT NULL default '1800',
  PRIMARY KEY  (PortalUserId),
  UNIQUE KEY ResourceId (ResourceId),
  UNIQUE KEY Login (Login),
  KEY CreatedOn (CreatedOn),
  KEY Status (Status),
  KEY Modified (Modified),
  KEY dob (dob),
  KEY IsBanned (IsBanned)
);

CREATE TABLE PortalUserCustomData (
  CustomDataId int(11) NOT NULL auto_increment,
  ResourceId int(10) unsigned NOT NULL default '0',
  KEY ResourceId (ResourceId),
  PRIMARY KEY  (CustomDataId)
);

CREATE TABLE SessionData (
  SessionKey varchar(50) NOT NULL default '',
  VariableName varchar(255) NOT NULL default '',
  VariableValue longtext NOT NULL,
  PRIMARY KEY  (SessionKey,VariableName),
  KEY SessionKey (SessionKey),
  KEY VariableName (VariableName)
);

CREATE TABLE Theme (
  ThemeId int(11) NOT NULL auto_increment,
  Name varchar(40) NOT NULL default '',
  Enabled int(11) NOT NULL default '1',
  Description varchar(255) default NULL,
  PrimaryTheme int(11) NOT NULL default '0',
  CacheTimeout int(11) NOT NULL default '0',
  StylesheetId int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (ThemeId),
  KEY Enabled (Enabled),
  KEY StylesheetId (StylesheetId),
  KEY PrimaryTheme (PrimaryTheme)
);

CREATE TABLE ThemeFiles (
  FileId int(11) NOT NULL auto_increment,
  ThemeId int(11) NOT NULL default '0',
  FileName varchar(255) NOT NULL default '',
  FilePath varchar(255) NOT NULL default '',
  Description varchar(255) default NULL,
  FileType int(11) NOT NULL default '0',
  FileFound tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (FileId),
  KEY theme (ThemeId),
  KEY FileName (FileName),
  KEY FilePath (FilePath),
  KEY FileFound (FileFound)
);

CREATE TABLE UserGroup (
  PortalUserId int(11) NOT NULL default '0',
  GroupId int(11) NOT NULL default '0',
  MembershipExpires int(10) unsigned default NULL,
  PrimaryGroup tinyint(4) NOT NULL default '1',
  ExpirationReminderSent tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (PortalUserId,GroupId),
  KEY GroupId (GroupId),
  KEY PrimaryGroup (PrimaryGroup),
  KEY MembershipExpires (MembershipExpires),
  KEY ExpirationReminderSent (ExpirationReminderSent)
);

CREATE TABLE UserSession (
  SessionKey int(10) unsigned NOT NULL default '0',
  CurrentTempKey int(10) unsigned default NULL,
  PrevTempKey int(10) unsigned default NULL,
  LastAccessed int(10) unsigned NOT NULL default '0',
  PortalUserId int(11) NOT NULL default '-2',
  `Language` int(11) NOT NULL default '1',
  Theme int(11) NOT NULL default '1',
  GroupId int(11) NOT NULL default '0',
  IpAddress varchar(20) NOT NULL default '0.0.0.0',
  `Status` int(11) NOT NULL default '1',
  GroupList varchar(255) default NULL,
  tz int(11) default NULL,
  PRIMARY KEY  (SessionKey),
  KEY UserId (PortalUserId),
  KEY LastAccessed (LastAccessed)
);

CREATE TABLE EmailLog (
  EmailLogId int(11) NOT NULL auto_increment,
  fromuser varchar(200) default NULL,
  addressto varchar(255) default NULL,
  `subject` varchar(255) default NULL,
  `timestamp` bigint(20) default '0',
  event varchar(100) default NULL,
  EventParams text NOT NULL,
  PRIMARY KEY  (EmailLogId),
  KEY `timestamp` (`timestamp`)
);

CREATE TABLE Cache (
  VarName varchar(255) NOT NULL default '',
  Data longtext,
  Cached int(11) default NULL,
  LifeTime int(11) NOT NULL default '-1',
  PRIMARY KEY  (VarName),
  KEY Cached (Cached)
);

CREATE TABLE StdDestinations (
  DestId int(11) NOT NULL auto_increment,
  DestType int(11) NOT NULL default '0',
  DestParentId int(11) default NULL,
  DestName varchar(255) NOT NULL default '',
  DestAbbr char(3) NOT NULL default '',
  DestAbbr2 char(2) default NULL,
  PRIMARY KEY  (DestId),
  KEY DestType (DestType),
  KEY DestParentId (DestParentId)
);

CREATE TABLE Category (
  CategoryId int(11) NOT NULL auto_increment,
  `Type` int(11) NOT NULL default '0',
  SymLinkCategoryId int(10) unsigned default NULL,
  ParentId int(11) NOT NULL default '0',
  Name varchar(255) NOT NULL default '',
  l1_Name varchar(255) NOT NULL default '',
  l2_Name varchar(255) NOT NULL default '',
  l3_Name varchar(255) NOT NULL default '',
  l4_Name varchar(255) NOT NULL default '',
  l5_Name varchar(255) NOT NULL default '',
  Filename varchar(255) NOT NULL default '',
  AutomaticFilename tinyint(3) unsigned NOT NULL default '1',
  Description text,
  l1_Description text,
  l2_Description text,
  l3_Description text,
  l4_Description text,
  l5_Description text,
  CreatedOn int(11) NOT NULL default '0',
  EditorsPick tinyint(4) NOT NULL default '0',
  `Status` tinyint(4) NOT NULL default '2',
  Priority int(11) NOT NULL default '0',
  MetaKeywords varchar(255) default NULL,
  CachedDescendantCatsQty int(11) default NULL,
  CachedNavbar text,
  l1_CachedNavbar text,
  l2_CachedNavbar text,
  l3_CachedNavbar text,
  l4_CachedNavbar text,
  l5_CachedNavbar text,
  CreatedById int(11) NOT NULL default '0',
  ResourceId int(11) default NULL,
  ParentPath TEXT NULL DEFAULT NULL,
  TreeLeft bigint(20) NOT NULL default '0',
  TreeRight bigint(20) NOT NULL default '0',
  NamedParentPath TEXT NULL DEFAULT NULL,
  MetaDescription varchar(255) default NULL,
  HotItem int(11) NOT NULL default '2',
  NewItem int(11) NOT NULL default '2',
  PopItem int(11) NOT NULL default '2',
  Modified int(11) NOT NULL default '0',
  ModifiedById int(11) NOT NULL default '0',
  CategoryTemplate varchar(255) NOT NULL default '',
  CachedCategoryTemplate varchar(255) NOT NULL default '',
  PRIMARY KEY  (CategoryId),
  UNIQUE KEY ResourceId (ResourceId),
  KEY ParentId (ParentId),
  KEY Modified (Modified),
  KEY Priority (Priority),
  KEY sorting (Name,Priority),
  KEY Filename (Filename(5)),
  KEY l1_Name (l1_Name(5)),
  KEY l2_Name (l2_Name(5)),
  KEY l3_Name (l3_Name(5)),
  KEY l4_Name (l4_Name(5)),
  KEY l5_Name (l5_Name(5)),
  KEY l1_Description (l1_Description(5)),
  KEY l2_Description (l2_Description(5)),
  KEY l3_Description (l3_Description(5)),
  KEY l4_Description (l4_Description(5)),
  KEY l5_Description (l5_Description(5)),
  KEY TreeLeft (TreeLeft),
  KEY TreeRight (TreeRight),
  KEY SymLinkCategoryId (SymLinkCategoryId),
  KEY Status (Status),
  KEY CreatedOn (CreatedOn),
  KEY EditorsPick (EditorsPick)
);

CREATE TABLE CategoryCustomData (
  CustomDataId int(11) NOT NULL auto_increment,
  ResourceId int(10) unsigned NOT NULL default '0',
  KEY ResourceId (ResourceId),
  PRIMARY KEY  (CustomDataId)
);

CREATE TABLE CategoryItems (
  `CategoryId` int(11) NOT NULL default '0',
  `ItemResourceId` int(11) NOT NULL default '0',
  `PrimaryCat` tinyint(4) NOT NULL default '0',
  `ItemPrefix` varchar(50) NOT NULL default '',
  `Filename` varchar(255) NOT NULL default '',
  UNIQUE KEY `CategoryId` (`CategoryId`,`ItemResourceId`),
  KEY `PrimaryCat` (`PrimaryCat`),
  KEY `ItemPrefix` (`ItemPrefix`),
  KEY `Filename` (`Filename`(4))
);

CREATE TABLE PermCache (
  PermCacheId int(11) NOT NULL auto_increment,
  CategoryId int(11) NOT NULL default '0',
  PermId int(11) NOT NULL default '0',
  ACL varchar(255) NOT NULL default '',
  PRIMARY KEY  (PermCacheId),
  KEY CategoryId (CategoryId),
  KEY PermId (PermId)
);

CREATE TABLE Stylesheets (
  StylesheetId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Description varchar(255) NOT NULL default '',
  AdvancedCSS text NOT NULL,
  LastCompiled int(10) unsigned NOT NULL default '0',
  Enabled int(11) NOT NULL default '0',
  PRIMARY KEY  (StylesheetId),
  KEY Enabled (Enabled),
  KEY LastCompiled (LastCompiled)
);

CREATE TABLE PopupSizes (
  PopupId int(10) unsigned NOT NULL auto_increment,
  TemplateName varchar(255) NOT NULL default '',
  PopupWidth int(11) NOT NULL default '0',
  PopupHeight int(11) NOT NULL default '0',
  PRIMARY KEY  (PopupId),
  KEY TemplateName (TemplateName)
);

CREATE TABLE Counters (
  CounterId int(10) unsigned NOT NULL auto_increment,
  Name varchar(100) NOT NULL default '',
  CountQuery text,
  CountValue text,
  LastCounted int(10) unsigned default NULL,
  LifeTime int(10) unsigned NOT NULL default '3600',
  IsClone tinyint(3) unsigned NOT NULL default '0',
  TablesAffected text,
  PRIMARY KEY  (CounterId),
  UNIQUE KEY Name (Name),
  KEY IsClone (IsClone),
  KEY LifeTime (LifeTime),
  KEY LastCounted (LastCounted)
);

CREATE TABLE Skins (
  `SkinId` int(11) NOT NULL auto_increment,
  `Name` varchar(255) default NULL,
  `CSS` text,
  `Logo` varchar(255) default NULL,
  `Options` text,
  `LastCompiled` int(11) NOT NULL default '0',
  `IsPrimary` int(1) NOT NULL default '0',
  PRIMARY KEY  (`SkinId`),
  KEY IsPrimary (IsPrimary),
  KEY LastCompiled (LastCompiled)
);

CREATE TABLE ChangeLogs (
  ChangeLogId bigint(20) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  SessionLogId int(11) NOT NULL default '0',
  `Action` tinyint(4) NOT NULL default '0',
  OccuredOn int(11) NOT NULL default '0',
  Prefix varchar(255) NOT NULL default '',
  ItemId bigint(20) NOT NULL default '0',
  Changes text NOT NULL,
  MasterPrefix varchar(255) NOT NULL default '',
  MasterId bigint(20) NOT NULL default '0',
  PRIMARY KEY  (ChangeLogId),
  KEY PortalUserId (PortalUserId),
  KEY SessionLogId (SessionLogId),
  KEY `Action` (`Action`),
  KEY OccuredOn (OccuredOn),
  KEY Prefix (Prefix),
  KEY MasterPrefix (MasterPrefix)
);

CREATE TABLE SessionLogs (
  SessionLogId bigint(20) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  SessionId int(10) NOT NULL default '0',
  `Status` tinyint(4) NOT NULL default '1',
  SessionStart int(11) NOT NULL default '0',
  SessionEnd int(11) default NULL,
  IP varchar(15) NOT NULL default '',
  AffectedItems int(11) NOT NULL default '0',
  PRIMARY KEY  (SessionLogId),
  KEY SessionId (SessionId),
  KEY `Status` (`Status`),
  KEY PortalUserId (PortalUserId)
);

CREATE TABLE StatisticsCapture (
  StatisticsId int(10) unsigned NOT NULL auto_increment,
  TemplateName varchar(255) NOT NULL default '',
  Hits int(10) unsigned NOT NULL default '0',
  LastHit int(11) NOT NULL default '0',
  ScriptTimeMin decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  ScriptTimeAvg decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  ScriptTimeMax decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlTimeMin decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlTimeAvg decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlTimeMax decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlCountMin decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlCountAvg decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  SqlCountMax decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  PRIMARY KEY  (StatisticsId),
  KEY TemplateName (TemplateName),
  KEY Hits (Hits),
  KEY LastHit (LastHit),
  KEY ScriptTimeMin (ScriptTimeMin),
  KEY ScriptTimeAvg (ScriptTimeAvg),
  KEY ScriptTimeMax (ScriptTimeMax),
  KEY SqlTimeMin (SqlTimeMin),
  KEY SqlTimeAvg (SqlTimeAvg),
  KEY SqlTimeMax (SqlTimeMax),
  KEY SqlCountMin (SqlCountMin),
  KEY SqlCountAvg (SqlCountAvg),
  KEY SqlCountMax (SqlCountMax)
);

CREATE TABLE SlowSqlCapture (
  CaptureId int(10) unsigned NOT NULL auto_increment,
  TemplateNames text,
  Hits int(10) unsigned NOT NULL default '0',
  LastHit int(11) NOT NULL default '0',
  SqlQuery text,
  TimeMin decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  TimeAvg decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  TimeMax decimal(40,20) unsigned NOT NULL default '0.00000000000000000000',
  QueryCrc int(11) NOT NULL default '0',
  PRIMARY KEY  (CaptureId),
  KEY Hits (Hits),
  KEY LastHit (LastHit),
  KEY TimeMin (TimeMin),
  KEY TimeAvg (TimeAvg),
  KEY TimeMax (TimeMax),
  KEY QueryCrc (QueryCrc)
);

CREATE TABLE Agents (
  AgentId int(11) NOT NULL auto_increment,
  AgentName varchar(255) NOT NULL default '',
  AgentType tinyint(3) unsigned NOT NULL default '1',
  Status tinyint(3) unsigned NOT NULL default '1',
  Event varchar(255) NOT NULL default '',
  RunInterval int(10) unsigned NOT NULL default '0',
  RunMode tinyint(3) unsigned NOT NULL default '2',
  LastRunOn int(10) unsigned default NULL,
  LastRunStatus tinyint(3) unsigned NOT NULL default '1',
  NextRunOn int(11) default NULL,
  RunTime int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (AgentId),
  KEY Status (Status),
  KEY RunInterval (RunInterval),
  KEY RunMode (RunMode),
  KEY AgentType (AgentType),
  KEY LastRunOn (LastRunOn),
  KEY LastRunStatus (LastRunStatus),
  KEY RunTime (RunTime),
  KEY NextRunOn (NextRunOn)
);

CREATE TABLE SpellingDictionary (
  SpellingDictionaryId int(11) NOT NULL auto_increment,
  MisspelledWord varchar(255) NOT NULL default '',
  SuggestedCorrection varchar(255) NOT NULL default '',
  PRIMARY KEY  (SpellingDictionaryId),
  KEY MisspelledWord (MisspelledWord),
  KEY SuggestedCorrection (SuggestedCorrection)
);

CREATE TABLE Thesaurus (
  ThesaurusId int(11) NOT NULL auto_increment,
  SearchTerm varchar(255) NOT NULL default '',
  ThesaurusTerm varchar(255) NOT NULL default '',
  ThesaurusType tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (ThesaurusId),
  KEY ThesaurusType (ThesaurusType),
  KEY SearchTerm (SearchTerm)
);

CREATE TABLE LocalesList (
  LocaleId int(11) NOT NULL auto_increment,
  LocaleIdentifier varchar(6) NOT NULL default '',
  LocaleName varchar(255) NOT NULL default '',
  Locale varchar(20) NOT NULL default '',
  ScriptTag varchar(255) NOT NULL default '',
  ANSICodePage varchar(10) NOT NULL default '',
  PRIMARY KEY (LocaleId)
);
