Index: branches/5.0.x/core/install/install_schema.sql
===================================================================
diff -u -r12641 -r12703
--- branches/5.0.x/core/install/install_schema.sql	(.../install_schema.sql)	(revision 12641)
+++ branches/5.0.x/core/install/install_schema.sql	(.../install_schema.sql)	(revision 12703)
@@ -80,16 +80,16 @@
 );
 
 CREATE TABLE EmailQueue (
-  EmailQueueId int(10) unsigned NOT NULL auto_increment,
-  ToEmail varchar(255) NOT NULL default '',
-  `Subject` varchar(255) NOT NULL default '',
+  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',
-  MailingId int(10) unsigned NOT NULL,
-  PRIMARY KEY  (EmailQueueId),
+  Queued int(10) unsigned DEFAULT NULL,
+  SendRetries int(10) unsigned NOT NULL DEFAULT '0',
+  LastSendRetry int(10) unsigned DEFAULT NULL,
+  MailingId int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (EmailQueueId),
   KEY LastSendRetry (LastSendRetry),
   KEY SendRetries (SendRetries),
   KEY MailingId (MailingId)
@@ -124,27 +124,27 @@
 );
 
 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,
-  IconDisabledURL 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',
+  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,
+  IconDisabledURL 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,
-  Locale varchar(10) NOT NULL default 'en-US',
-  UserDocsUrl varchar(255) NOT NULL,
-  PRIMARY KEY  (LanguageId),
+  Locale varchar(10) NOT NULL DEFAULT 'en-US',
+  UserDocsUrl varchar(255) NOT NULL DEFAULT '',
+  PRIMARY KEY (LanguageId),
   KEY Enabled (Enabled),
   KEY PrimaryLang (PrimaryLang),
   KEY AdminInterfaceLang (AdminInterfaceLang),
@@ -167,23 +167,23 @@
 );
 
 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,
+  VariableId bigint(20) NOT NULL AUTO_INCREMENT,
+  PortalUserId int(11) NOT NULL DEFAULT '0',
+  VariableName varchar(255) NOT NULL DEFAULT '',
+  VariableValue text,
   PRIMARY KEY (VariableId),
   KEY UserId (PortalUserId),
   KEY VariableName (VariableName)
 );
 
 CREATE TABLE Phrase (
   Phrase varchar(255) NOT NULL DEFAULT '',
-  PhraseKey varchar(255) NOT NULL,
-  Translation text NOT NULL,
+  PhraseKey varchar(255) NOT NULL DEFAULT '',
+  Translation text,
   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',
+  LastChanged int(10) unsigned DEFAULT NULL,
   LastChangeIP varchar(15) NOT NULL DEFAULT '',
   Module varchar(30) NOT NULL DEFAULT 'In-Portal',
   PRIMARY KEY (PhraseId),
@@ -194,13 +194,13 @@
 );
 
 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',
+  Template varchar(40) NOT NULL DEFAULT '',
+  PhraseList text,
+  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),
+  PRIMARY KEY (Template),
   KEY CacheDate (CacheDate),
   KEY ThemeId (ThemeId),
   KEY StylesheetId (StylesheetId)
@@ -223,38 +223,38 @@
 );
 
 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),
+  PortalUserId int(11) NOT NULL AUTO_INCREMENT,
+  Login varchar(255) DEFAULT NULL,
+  `Password` varchar(255) 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(11) 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 '1',
+  Modified int(11) DEFAULT NULL,
+  dob int(11) DEFAULT NULL,
+  tz int(11) DEFAULT NULL,
+  ip varchar(20) DEFAULT NULL,
+  IsBanned tinyint(1) NOT NULL DEFAULT '0',
+  PassResetTime int(11) unsigned DEFAULT NULL,
+  PwResetConfirm varchar(255) DEFAULT NULL,
+  PwRequestTime int(11) unsigned 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 `Status` (`Status`),
   KEY Modified (Modified),
   KEY dob (dob),
   KEY IsBanned (IsBanned)
@@ -268,10 +268,10 @@
 );
 
 CREATE TABLE SessionData (
-  SessionKey varchar(50) NOT NULL default '',
-  VariableName varchar(255) NOT NULL default '',
-  VariableValue longtext NOT NULL,
-  PRIMARY KEY  (SessionKey,VariableName),
+  SessionKey varchar(50) NOT NULL DEFAULT '',
+  VariableName varchar(255) NOT NULL DEFAULT '',
+  VariableValue longtext,
+  PRIMARY KEY (SessionKey,VariableName),
   KEY SessionKey (SessionKey),
   KEY VariableName (VariableName)
 );
@@ -338,14 +338,14 @@
 );
 
 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),
+  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,
+  PRIMARY KEY (EmailLogId),
   KEY `timestamp` (`timestamp`)
 );
 
@@ -389,9 +389,9 @@
   l3_Description text,
   l4_Description text,
   l5_Description text,
-  CreatedOn int(11) NOT NULL DEFAULT '0',
+  CreatedOn int(11) DEFAULT NULL,
   EditorsPick tinyint(4) NOT NULL DEFAULT '0',
-  `Status` tinyint(4) NOT NULL DEFAULT '2',
+  `Status` tinyint(4) NOT NULL DEFAULT '1',
   Priority int(11) NOT NULL DEFAULT '0',
   MetaKeywords text,
   CachedDescendantCatsQty int(11) DEFAULT NULL,
@@ -411,7 +411,7 @@
   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',
+  Modified int(11) DEFAULT NULL,
   ModifiedById int(11) NOT NULL DEFAULT '0',
   CachedTemplate varchar(255) NOT NULL DEFAULT '',
   Template varchar(255) NOT NULL DEFAULT '#inherit#',
@@ -496,13 +496,13 @@
 );
 
 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),
+  StylesheetId int(11) NOT NULL AUTO_INCREMENT,
+  `Name` varchar(255) NOT NULL DEFAULT '',
+  Description varchar(255) NOT NULL DEFAULT '',
+  AdvancedCSS text,
+  LastCompiled int(10) unsigned DEFAULT NULL,
+  Enabled int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (StylesheetId),
   KEY Enabled (Enabled),
   KEY LastCompiled (LastCompiled)
 );
@@ -533,32 +533,32 @@
 );
 
 CREATE TABLE Skins (
-  SkinId int(11) NOT NULL auto_increment,
-  `Name` varchar(255) default NULL,
+  SkinId int(11) NOT NULL AUTO_INCREMENT,
+  `Name` varchar(255) DEFAULT NULL,
   CSS text,
-  Logo varchar(255) default NULL,
-  LogoBottom varchar(255) NOT NULL,
-  LogoLogin varchar(255) NOT NULL,
-  Options text,
-  LastCompiled int(11) NOT NULL default '0',
-  IsPrimary int(1) NOT NULL default '0',
-  PRIMARY KEY  (SkinId),
+  Logo varchar(255) DEFAULT NULL,
+  LogoBottom varchar(255) NOT NULL DEFAULT '',
+  LogoLogin varchar(255) NOT NULL DEFAULT '',
+  `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),
+  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) DEFAULT NULL,
+  Prefix varchar(255) NOT NULL DEFAULT '',
+  ItemId bigint(20) NOT NULL DEFAULT '0',
+  Changes text,
+  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`),
@@ -568,15 +568,15 @@
 );
 
 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),
+  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) DEFAULT NULL,
+  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)
@@ -756,24 +756,24 @@
 );
 
 CREATE TABLE ItemReview (
-  ReviewId int(11) NOT NULL auto_increment,
-  CreatedOn INT UNSIGNED NULL DEFAULT NULL,
-  ReviewText longtext NOT NULL,
-  Rating tinyint(3) unsigned default 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),
+  ReviewId int(11) NOT NULL AUTO_INCREMENT,
+  CreatedOn int(10) unsigned DEFAULT NULL,
+  ReviewText longtext,
+  Rating tinyint(3) unsigned DEFAULT 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),
   KEY CreatedOn (CreatedOn),
   KEY ItemId (ItemId),
   KEY ItemType (ItemType),
   KEY Priority (Priority),
-  KEY Status (Status)
+  KEY `Status` (`Status`)
 );
 
 CREATE TABLE ItemTypes (
@@ -795,19 +795,19 @@
 );
 
 CREATE TABLE ItemFiles (
-  FileId int(11) NOT NULL auto_increment,
-  ResourceId int(11) unsigned NOT NULL default '0',
-  FileName varchar(255) NOT NULL default '',
-  FilePath varchar(255) NOT NULL default '',
-  Size int(11) NOT NULL default '0',
-  `Status` tinyint(4) NOT NULL default '1',
-  CreatedOn int(11) unsigned NOT NULL default '0',
-  CreatedById int(11) NOT NULL default '-1',
-  MimeType varchar(255) NOT NULL default '',
-  PRIMARY KEY  (FileId),
+  FileId int(11) NOT NULL AUTO_INCREMENT,
+  ResourceId int(11) unsigned NOT NULL DEFAULT '0',
+  FileName varchar(255) NOT NULL DEFAULT '',
+  FilePath varchar(255) NOT NULL DEFAULT '',
+  Size int(11) NOT NULL DEFAULT '0',
+  `Status` tinyint(4) NOT NULL DEFAULT '1',
+  CreatedOn int(11) unsigned DEFAULT NULL,
+  CreatedById int(11) NOT NULL DEFAULT '-1',
+  MimeType varchar(255) NOT NULL DEFAULT '',
+  PRIMARY KEY (FileId),
   KEY ResourceId (ResourceId),
   KEY CreatedOn (CreatedOn),
-  KEY Status (Status)
+  KEY `Status` (`Status`)
 );
 
 CREATE TABLE Relationship (
@@ -931,54 +931,54 @@
 );
 
 CREATE TABLE ImportScripts (
-  ImportId INT(11) NOT NULL auto_increment,
-  Name VARCHAR(255) NOT NULL DEFAULT '',
-  Description TEXT NOT NULL,
-  Prefix VARCHAR(10) NOT NULL DEFAULT '',
-  Module VARCHAR(50) NOT NULL DEFAULT '',
-  ExtraFields VARCHAR(255) NOT NULL DEFAULT '',
-  Type VARCHAR(10) NOT NULL DEFAULT '',
-  Status TINYINT NOT NULL,
+  ImportId int(11) NOT NULL AUTO_INCREMENT,
+  `Name` varchar(255) NOT NULL DEFAULT '',
+  Description text,
+  Prefix varchar(10) NOT NULL DEFAULT '',
+  Module varchar(50) NOT NULL DEFAULT '',
+  ExtraFields varchar(255) NOT NULL DEFAULT '',
+  `Type` varchar(10) NOT NULL DEFAULT '',
+  `Status` tinyint(4) NOT NULL DEFAULT '1',
   PRIMARY KEY (ImportId),
   KEY Module (Module),
-  KEY Status (Status)
+  KEY `Status` (`Status`)
 );
 
 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),
+  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,
+  Description text,
+  `Type` tinyint(4) NOT NULL DEFAULT '0',
+  AdvancedCSS text,
+  ParentId int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (SelectorId),
   KEY StylesheetId (StylesheetId),
   KEY ParentId (ParentId),
   KEY `Type` (`Type`)
 );
 
 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),
+  VisitId int(11) NOT NULL AUTO_INCREMENT,
+  VisitDate int(10) unsigned DEFAULT NULL,
+  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),
   KEY VisitDate (VisitDate)
 );
 
 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),
+  CacheId int(11) NOT NULL AUTO_INCREMENT,
+  CacheName varchar(255) NOT NULL DEFAULT '',
+  VarName int(11) NOT NULL DEFAULT '0',
+  VarValue text,
+  PRIMARY KEY (CacheId),
   KEY CacheName (CacheName),
   KEY VarName (VarName)
 );
@@ -1004,19 +1004,19 @@
 );
 
 CREATE TABLE MailingLists (
-  MailingId int(10) unsigned NOT NULL auto_increment,
-  PortalUserId int(11) NOT NULL default '-1',
+  MailingId int(10) unsigned NOT NULL AUTO_INCREMENT,
+  PortalUserId int(11) NOT NULL DEFAULT '-1',
   `To` longtext,
   ToParsed longtext,
   Attachments text,
-  `Subject` varchar(255) NOT NULL,
+  `Subject` varchar(255) NOT NULL DEFAULT '',
   MessageText longtext,
   MessageHtml longtext,
-  `Status` tinyint(3) unsigned NOT NULL default '1',
-  EmailsQueued int(10) unsigned NOT NULL,
-  EmailsSent int(10) unsigned NOT NULL,
-  EmailsTotal int(10) unsigned NOT NULL,
-  PRIMARY KEY  (MailingId),
+  `Status` tinyint(3) unsigned NOT NULL DEFAULT '1',
+  EmailsQueued int(10) unsigned NOT NULL DEFAULT '0',
+  EmailsSent int(10) unsigned NOT NULL DEFAULT '0',
+  EmailsTotal int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (MailingId),
   KEY EmailsTotal (EmailsTotal),
   KEY EmailsSent (EmailsSent),
   KEY EmailsQueued (EmailsQueued),
@@ -1038,22 +1038,22 @@
 );
 
 CREATE TABLE FormFields (
-  FormFieldId int(11) NOT NULL auto_increment,
-  FormId int(11) NOT NULL default '0',
-  Type int(11) NOT NULL default '0',
-  FieldName varchar(255) NOT NULL default '',
-  FieldLabel varchar(255) default NULL,
-  Heading varchar(255) default NULL,
-  Prompt varchar(255) default NULL,
-  ElementType varchar(50) NOT NULL default '',
-  ValueList varchar(255) default NULL,
-  Priority int(11) NOT NULL default '0',
-  IsSystem tinyint(3) unsigned NOT NULL default '0',
-  Required tinyint(1) NOT NULL default '0',
-  DisplayInGrid tinyint(1) NOT NULL default '1',
-  DefaultValue text NOT NULL,
-  Validation TINYINT NOT NULL DEFAULT '0',
-  PRIMARY KEY  (FormFieldId),
+  FormFieldId int(11) NOT NULL AUTO_INCREMENT,
+  FormId int(11) NOT NULL DEFAULT '0',
+  `Type` int(11) NOT NULL DEFAULT '0',
+  FieldName varchar(255) NOT NULL DEFAULT '',
+  FieldLabel varchar(255) DEFAULT NULL,
+  Heading varchar(255) DEFAULT NULL,
+  Prompt varchar(255) DEFAULT NULL,
+  ElementType varchar(50) NOT NULL DEFAULT '',
+  ValueList varchar(255) DEFAULT NULL,
+  Priority int(11) NOT NULL DEFAULT '0',
+  IsSystem tinyint(3) unsigned NOT NULL DEFAULT '0',
+  Required tinyint(1) NOT NULL DEFAULT '0',
+  DisplayInGrid tinyint(1) NOT NULL DEFAULT '1',
+  DefaultValue text,
+  Validation tinyint(4) NOT NULL DEFAULT '0',
+  PRIMARY KEY (FormFieldId),
   KEY `Type` (`Type`),
   KEY FormId (FormId),
   KEY Priority (Priority),
@@ -1062,10 +1062,10 @@
 );
 
 CREATE TABLE FormSubmissions (
-  FormSubmissionId int(11) NOT NULL auto_increment,
-  FormId int(11) NOT NULL default '0',
-  SubmissionTime int(11) NOT NULL default '0',
-  PRIMARY KEY  (FormSubmissionId),
+  FormSubmissionId int(11) NOT NULL AUTO_INCREMENT,
+  FormId int(11) NOT NULL DEFAULT '0',
+  SubmissionTime int(11) DEFAULT NULL,
+  PRIMARY KEY (FormSubmissionId),
   KEY FormId (FormId),
   KEY SubmissionTime (SubmissionTime)
 );
@@ -1078,12 +1078,12 @@
 );
 
 CREATE TABLE Semaphores (
-  SemaphoreId int(11) NOT NULL auto_increment,
-  SessionKey int(10) unsigned NOT NULL,
-  Timestamp int(10) unsigned NOT NULL,
-  MainPrefix varchar(255) NOT NULL,
-  PRIMARY KEY  (SemaphoreId),
+  SemaphoreId int(11) NOT NULL AUTO_INCREMENT,
+  SessionKey int(10) unsigned NOT NULL DEFAULT '0',
+  `Timestamp` int(10) unsigned NOT NULL DEFAULT '0',
+  MainPrefix varchar(255) NOT NULL DEFAULT '',
+  PRIMARY KEY (SemaphoreId),
   KEY SessionKey (SessionKey),
-  KEY Timestamp (Timestamp),
+  KEY `Timestamp` (`Timestamp`),
   KEY MainPrefix (MainPrefix)
 );
\ No newline at end of file
