UPDATE Editor
  SET Password = 'changemenow', Disabled = 0
  WHERE ID=1;

CREATE TABLE IF NOT EXISTS Audience (
  ID int(11) NOT NULL auto_increment,
  Value char(255) NOT NULL default '',
  Label char(255) NOT NULL default '',
  PRIMARY KEY  (ID),
  UNIQUE KEY Name_uk (Value)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Base_Document (
  ID int(11) NOT NULL auto_increment,
  Editor_ID int(11) NOT NULL default '0',
  Document_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (ID),
  UNIQUE KEY Editor_Document_Owner_uk (Editor_ID,Document_ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Contributor (
  ID int(11) NOT NULL auto_increment,
  Editor_ID int(11) NOT NULL default '0',
  Document_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (ID),
  UNIQUE KEY Editor_Document_Contributor_uk (Editor_ID,Document_ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Document_Audience (
  ID int(11) NOT NULL auto_increment,
  Document_ID int(11) NOT NULL default '0',
  Audience_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Document_Index (
  ID int(11) NOT NULL auto_increment,
  Record_ID int(11) NOT NULL default '0',
  Column_Name char(50) NOT NULL default '',
  Keyword char(100) NOT NULL default '',
  PRIMARY KEY  (ID),
  UNIQUE KEY RecordKeywordUK (Record_ID,Column_Name,Keyword),
  KEY DocumentIndex (Keyword)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Document (
  ID int(11) NOT NULL auto_increment,
  Parent_ID int(11) default NULL,
  Cache_Control int(11) NOT NULL default '0',
  Template varchar(255) NOT NULL default '',
  Description text NOT NULL,
  Keywords text NOT NULL,
  Date_Created datetime NOT NULL default '0000-00-00 00:00:00',
  Date_Last_Modified datetime NOT NULL default '0000-00-00 00:00:00',
  Editor_Created_ID int(11) NOT NULL default '0',
  Editor_Last_Modified_ID int(11) NOT NULL default '0',
  Name varchar(50) NOT NULL default '',
  Full_Path varchar(255) NOT NULL default '',
  Title varchar(255) NOT NULL default '',
  Lang varchar(8) NOT NULL default '',
  Rights text,
  Publisher text,
  Source text,
  Relation text,
  Coverage text,
  Body longtext,
  Sibling_Position int(11) default NULL,
  Sort_By varchar(50) default NULL,
  Order_By int(11) default NULL,
  PRIMARY KEY  (ID),
  UNIQUE KEY Full_Path_UK (Full_Path),
  KEY Parent_ID_IDX (Parent_ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Editor (
  ID int(11) NOT NULL auto_increment,
  Login char(15) NOT NULL default '',
  Password char(15) NOT NULL default '',
  Email char(255) NOT NULL default '',
  First_Name char(50) default NULL,
  Family_Name char(50) default NULL,
  Disabled int(11) NOT NULL default '0',
  PRIMARY KEY  (ID),
  UNIQUE KEY login_uk (Login)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Poll_Results (
  ID int(11) NOT NULL auto_increment,
  Poll_ID char(100) NOT NULL default '',
  Answer char(100) NOT NULL default '',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Preference_Audience (
  ID int(11) NOT NULL auto_increment,
  Editor_ID int(11) NOT NULL default '0',
  Audience_ID int(11) NOT NULL default '0',
  Value int(11) NOT NULL default '0',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Preference_Language (
  ID int(11) NOT NULL auto_increment,
  Editor_ID int(11) NOT NULL default '0',
  Language_ID char(25) NOT NULL default '',
  Value int(11) NOT NULL default '0',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Preference (
  ID int(11) NOT NULL auto_increment,
  Editor_ID int(11) NOT NULL default '0',
  Name char(255) NOT NULL default '',
  Value char(255) NOT NULL default '',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Redirect (
  ID int(11) NOT NULL auto_increment,
  Old_Path char(255) NOT NULL default '',
  New_Path char(255) NOT NULL default '',
  PRIMARY KEY  (ID),
  UNIQUE KEY Old_New_Uk (Old_Path)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Session (
  ID char(50) NOT NULL default '',
  Last_Time int(11) NOT NULL default '0',
  IP char(20) default NULL,
  Editor_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (ID)
) TYPE=MyISAM;

CREATE TABLE IF NOT EXISTS Tickets (
  ID char(25) NOT NULL default '',
  ExpiryDate datetime NOT NULL default '0000-00-00 00:00:00',
  Email char(255) default NULL,
  Action char(25) default NULL,
  PRIMARY KEY  (ID)
) TYPE=MyISAM;


ALTER TABLE Audience
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Value char(255) NOT NULL default '',
  MODIFY Label char(255) NOT NULL default '';

ALTER TABLE Base_Document
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Editor_ID int(11) NOT NULL default '0',
  MODIFY Document_ID int(11) NOT NULL default '0';

ALTER TABLE Contributor
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Editor_ID int(11) NOT NULL default '0',
  MODIFY Document_ID int(11) NOT NULL default '0';

ALTER TABLE Document_Audience
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Document_ID int(11) NOT NULL default '0',
  MODIFY Audience_ID int(11) NOT NULL default '0';

ALTER TABLE Document_Index
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Record_ID int(11) NOT NULL default '0',
  MODIFY Column_Name char(50) NOT NULL default '',
  MODIFY Keyword char(100) NOT NULL default '';

ALTER TABLE Document
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Parent_ID int(11) default NULL,
  MODIFY Cache_Control int(11) NOT NULL default '0',
  MODIFY Template varchar(255) NOT NULL default '',
  MODIFY Description text NOT NULL,
  MODIFY Keywords text NOT NULL,
  MODIFY Date_Created datetime NOT NULL default '0000-00-00 00:00:00',
  MODIFY Date_Last_Modified datetime NOT NULL default '0000-00-00 00:00:00',
  MODIFY Editor_Created_ID int(11) NOT NULL default '0',
  MODIFY Editor_Last_Modified_ID int(11) NOT NULL default '0',
  MODIFY Name varchar(50) NOT NULL default '',
  MODIFY Full_Path varchar(255) NOT NULL default '',
  MODIFY Title varchar(255) NOT NULL default '',
  MODIFY Lang varchar(8) NOT NULL default '',
  MODIFY Rights text,
  MODIFY Publisher text,
  MODIFY Source text,
  MODIFY Relation text,
  MODIFY Coverage text,
  MODIFY Body longtext,
  MODIFY Sibling_Position int(11) default NULL,
  MODIFY Sort_By varchar(50) default NULL,
  MODIFY Order_By int(11) default NULL;

ALTER TABLE Editor
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Login char(15) NOT NULL default '',
  MODIFY Password char(15) NOT NULL default '',
  MODIFY Email char(255) NOT NULL default '',
  MODIFY First_Name char(50) default NULL,
  MODIFY Family_Name char(50) default NULL,
  MODIFY Disabled int(11) NOT NULL default '0';

ALTER TABLE Poll_Results
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Poll_ID char(100) NOT NULL default '',
  MODIFY Answer char(100) NOT NULL default '';

ALTER TABLE Preference_Audience
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Editor_ID int(11) NOT NULL default '0',
  MODIFY Audience_ID int(11) NOT NULL default '0',
  MODIFY Value int(11) NOT NULL default '0';

ALTER TABLE Preference_Language
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Editor_ID int(11) NOT NULL default '0',
  MODIFY Language_ID char(25) NOT NULL default '',
  MODIFY Value int(11) NOT NULL default '0';

ALTER TABLE Preference
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Editor_ID int(11) NOT NULL default '0',
  MODIFY Name char(255) NOT NULL default '',
  MODIFY Value char(255) NOT NULL default '';

ALTER TABLE Redirect
  MODIFY ID int(11) NOT NULL auto_increment,
  MODIFY Old_Path char(255) NOT NULL default '',
  MODIFY New_Path char(255) NOT NULL default '';

ALTER TABLE Session
  MODIFY ID char(50) NOT NULL default '',
  MODIFY Last_Time int(11) NOT NULL default '0',
  MODIFY IP char(20) default NULL,
  MODIFY Editor_ID int(11) NOT NULL default '0';

ALTER TABLE Tickets
  MODIFY ID char(25) NOT NULL default '',
  MODIFY ExpiryDate datetime NOT NULL default '0000-00-00 00:00:00',
  MODIFY Email char(255) default NULL,
  MODIFY Action char(25) default NULL;


