CREATE TABLE BanRules (
  RuleId int(11) NOT NULL auto_increment,
  RuleType tinyint(4) NOT NULL default '0',
  ItemField varchar(255) default NULL,
  ItemVerb tinyint(4) NOT NULL default '0',
  ItemValue varchar(255) NOT NULL default '',
  ItemType int(11) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  Status tinyint(4) NOT NULL default '1',
  ErrorTag varchar(255) default NULL,
  PRIMARY KEY  (RuleId)
)

# --------------------------------------------------------

CREATE TABLE CountCache (
  ListType int(11) NOT NULL default '0',
  ItemType int(11) NOT NULL default '-1',
  Value int(11) NOT NULL default '0',
  CountCacheId int(11) NOT NULL auto_increment,
  LastUpdate int(11) NOT NULL default '0',
  ExtraId varchar(50) default NULL,
  TodayOnly tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (CountCacheId)
)

# --------------------------------------------------------

CREATE TABLE Favorites (
  FavoriteId int(11) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  ResourceId int(11) NOT NULL default '0',
  ItemTypeId int(11) NOT NULL default '0',
  Modified int(11) NOT NULL default '0',
  PRIMARY KEY  (FavoriteId),
  UNIQUE KEY main (PortalUserId,ResourceId)
)

# --------------------------------------------------------

CREATE TABLE Images (
  ImageId int(11) NOT NULL auto_increment,
  ResourceId int(11) NOT NULL default '0',
  Url varchar(255) NOT NULL default '',
  Name varchar(255) NOT NULL default '',
  AltName VARCHAR(255) NOT NULL DEFAULT '',
  ImageIndex int(11) NOT NULL default '0',
  LocalImage tinyint(4) NOT NULL default '1',
  LocalPath varchar(240) NOT NULL default '',
  Enabled int(11) NOT NULL default '1',
  DefaultImg int(11) NOT NULL default '0',
  ThumbUrl varchar(255) default NULL,
  Priority int(11) NOT NULL default '0',
  ThumbPath varchar(255) default NULL,
  LocalThumb tinyint(4) NOT NULL default '1',
  SameImages tinyint(4) NOT NULL default '1',
  PRIMARY KEY  (ImageId),
  KEY ResourceId (ResourceId)
)

# --------------------------------------------------------

CREATE TABLE ItemRating (
  RatingId int(11) NOT NULL auto_increment,
  IPAddress varchar(255) NOT NULL default '',
  CreatedOn INT UNSIGNED NULL DEFAULT NULL,
  RatingValue int(11) NOT NULL default '0',
  ItemId int(11) NOT NULL default '0',
  PRIMARY KEY  (RatingId)
)

# --------------------------------------------------------

CREATE TABLE ItemReview (
  ReviewId int(11) NOT NULL auto_increment,
  CreatedOn INT UNSIGNED NULL DEFAULT NULL,
  ReviewText longtext NOT NULL,
  IPAddress varchar(255) NOT NULL default '',
  ItemId int(11) NOT NULL default '0',
  CreatedById int(11) NOT NULL default '-1',
  ItemType tinyint(4) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  Status tinyint(4) NOT NULL default '2',
  TextFormat int(11) NOT NULL default '0',
  Module varchar(255) NOT NULL default '',
  PRIMARY KEY  (ReviewId)
)

# --------------------------------------------------------

CREATE TABLE ItemTypes (
  ItemType int(11) NOT NULL default '0',
  Module varchar(50) NOT NULL default '',
  Prefix varchar(20) NOT NULL default '',
  SourceTable varchar(100) NOT NULL default '',
  TitleField varchar(50) default NULL,
  CreatorField varchar(255) NOT NULL default '',
  PopField varchar(255) default NULL,
  RateField varchar(255) default NULL,
  LangVar varchar(255) NOT NULL default '',
  PrimaryItem int(11) NOT NULL default '0',
  EditUrl varchar(255) NOT NULL default '',
  ClassName varchar(40) NOT NULL default '',
  ItemName varchar(50) NOT NULL default '',
  PRIMARY KEY  (ItemType),
  KEY Module (Module)
)

# --------------------------------------------------------

CREATE TABLE Relationship (
  RelationshipId int(11) NOT NULL auto_increment,
  SourceId int(11) default NULL,
  TargetId int(11) default NULL,
  SourceType tinyint(4) NOT NULL default '0',
  TargetType tinyint(4) NOT NULL default '0',
  Type int(11) NOT NULL default '0',
  Enabled int(11) NOT NULL default '1',
  Priority int(11) NOT NULL default '0',
  PRIMARY KEY  (RelationshipId),
  KEY RelSource (SourceId),
  KEY RelTarget (TargetId)
)

# --------------------------------------------------------

CREATE TABLE SearchConfig (
  TableName varchar(40) NOT NULL default '',
  FieldName varchar(40) NOT NULL default '',
  SimpleSearch tinyint(4) NOT NULL default '1',
  AdvancedSearch tinyint(4) NOT NULL default '1',
  Description varchar(255) default NULL,
  DisplayName varchar(80) default NULL,
  ModuleName VARCHAR(20) NOT NULL DEFAULT 'In-Portal',
  ConfigHeader varchar(255) default NULL,
  DisplayOrder int(11) NOT NULL default '0',
  SearchConfigId int(11) NOT NULL auto_increment,
  Priority int(11) NOT NULL default '0',
  FieldType varchar(20) NOT NULL default 'text',
  ForeignField TEXT,
  JoinClause TEXT,
  IsWhere text,
  IsNotWhere text,
  ContainsWhere text,
  NotContainsWhere text,
  CustomFieldId int(11) default NULL,
  PRIMARY KEY  (SearchConfigId)
)

# --------------------------------------------------------

CREATE TABLE SearchLog (
  SearchLogId int(11) NOT NULL auto_increment,
  Keyword varchar(255) NOT NULL default '',
  Indices bigint(20) NOT NULL default '0',
  SearchType int(11) NOT NULL default '0',
  PRIMARY KEY  (SearchLogId)
)

# --------------------------------------------------------

CREATE TABLE IgnoreKeywords (
  keyword varchar(20) NOT NULL default '',
  PRIMARY KEY  (keyword)
)

# --------------------------------------------------------

CREATE TABLE SpamControl (
  ItemResourceId int(11) NOT NULL default '0',
  IPaddress varchar(20) NOT NULL default '',
  Expire INT UNSIGNED NULL DEFAULT NULL,
  PortalUserId int(11) NOT NULL default '0',
  DataType varchar(20) default NULL
)

# --------------------------------------------------------

CREATE TABLE StatItem (
  StatItemId int(11) NOT NULL auto_increment,
  Module varchar(20) NOT NULL default '',
  ValueSQL varchar(255) default NULL,
  ResetSQL varchar(255) default NULL,
  ListLabel varchar(255) NOT NULL default '',
  Priority int(11) NOT NULL default '0',
  AdminSummary int(11) NOT NULL default '0',
  PRIMARY KEY  (StatItemId)
)

# --------------------------------------------------------

CREATE TABLE SuggestMail (
  email varchar(255) NOT NULL default '',
  sent INT UNSIGNED NULL DEFAULT NULL,
  PRIMARY KEY  (email)
)

# --------------------------------------------------------

CREATE TABLE SysCache (
  SysCacheId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Value mediumtext,
  Expire INT UNSIGNED NULL DEFAULT NULL,
  Module varchar(20) default NULL,
  Context varchar(255) default NULL,
  GroupList varchar(255) NOT NULL default '',
  PRIMARY KEY  (SysCacheId),
  KEY Name (Name)
)

# --------------------------------------------------------

CREATE TABLE TagLibrary (
  TagId int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL default '',
  description text,
  example text,
  scope varchar(20) NOT NULL default 'global',
  PRIMARY KEY  (TagId)
)

# --------------------------------------------------------

CREATE TABLE TagAttributes (
  AttrId int(11) NOT NULL auto_increment,
  TagId int(11) NOT NULL default '0',
  Name varchar(255) NOT NULL default '',
  AttrType varchar(20) default NULL,
  DefValue varchar(255) default NULL,
  Description TEXT,
  Required int(11) NOT NULL default '0',
  PRIMARY KEY  (AttrId)
)

# --------------------------------------------------------

CREATE TABLE ImportScripts (
  is_id smallint(5) unsigned NOT NULL auto_increment,
  is_Module varchar(50) NOT NULL default '',
  is_string_id varchar(10) NOT NULL default '',
  is_script varchar(100) NOT NULL default '',
  is_label varchar(255) NOT NULL default '',
  is_field_prefix varchar(50) NOT NULL default '',
  is_requred_fields varchar(255) NOT NULL default '',
  is_enabled tinyint(1) unsigned NOT NULL default '0',
  is_type varchar(10) NOT NULL default '',
  PRIMARY KEY  (is_id)
)

# --------------------------------------------------------

CREATE TABLE StylesheetSelectors (
  SelectorId int(11) NOT NULL auto_increment,
  StylesheetId int(11) NOT NULL default '0',
  Name varchar(255) NOT NULL default '',
  SelectorName varchar(255) NOT NULL default '',
  SelectorData text NOT NULL,
  Description text NOT NULL,
  Type tinyint(4) NOT NULL default '0',
  AdvancedCSS text NOT NULL,
  ParentId int(11) NOT NULL default '0',
  PRIMARY KEY  (SelectorId)
)

# --------------------------------------------------------

CREATE TABLE Visits (
  VisitId int(11) NOT NULL auto_increment,
  VisitDate int(10) unsigned NOT NULL default '0',
  Referer varchar(255) NOT NULL default '',
  IPAddress varchar(15) NOT NULL default '',
  AffiliateId int(10) unsigned NOT NULL default '0',
  PortalUserId int(11) NOT NULL default '-2',
  PRIMARY KEY  (VisitId),
  KEY PortalUserId (PortalUserId),
  KEY AffiliateId (AffiliateId)
)

# --------------------------------------------------------

CREATE TABLE ImportCache (
  CacheId int(11) NOT NULL auto_increment,
  CacheName varchar(255) NOT NULL default '',
  VarName int(11) NOT NULL default '0',
  VarValue text NOT NULL,
  PRIMARY KEY  (CacheId),
  KEY CacheName (CacheName),
  KEY VarName (VarName)
)

# --------------------------------------------------------
