<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- ***** BEGIN LICENSE BLOCK *****
   - This file is part of DotClear.
   - Copyright (c) 2004 Olivier Meunier and contributors. All rights
   - reserved.
   -
   - DotClear is free software; you can redistribute it and/or modify
   - it under the terms of the GNU General Public License as published by
   - the Free Software Foundation; either version 2 of the License, or
   - (at your option) any later version.
   - 
   - DotClear is distributed in the hope that it will be useful,
   - but WITHOUT ANY WARRANTY; without even the implied warranty of
   - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   - GNU General Public License for more details.
   - 
   - You should have received a copy of the GNU General Public License
   - along with DotClear; if not, write to the Free Software
   - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   -
   - ***** END LICENSE BLOCK ***** -->
<database>
  
  <!--
  Suppression des tables, UNIQUEMENT POUR TEST. NE PAS DECOMMENTER.
  
  <action id="droptables" label="Drop tables">
  DROP TABLE IF EXISTS `{{PREFIX}}categorie`, `{{PREFIX}}comment`,
  `{{PREFIX}}log`, `{{PREFIX}}ping`, `{{PREFIX}}post`, `{{PREFIX}}user`
  </action>
  
  -->
  
  <!-- USER -->
  <action id="user" label="Create table %s" string="{{PREFIX}}user">
    <test eq="neq" value="{{PREFIX}}user" label="Table %s exists"
    string="{{PREFIX}}user">SHOW TABLES LIKE '{{PREFIX}}user'</test>
    
    CREATE TABLE `{{PREFIX}}user` (
    `user_id` varchar(32) binary NOT NULL default '',
    `user_level` int(11) NOT NULL default '0',
    `user_pwd` varchar(32) binary NOT NULL default '',
    `user_nom` varchar(255) binary default NULL,
    `user_prenom` varchar(255) binary default NULL,
    `user_pseudo` varchar(255) binary default NULL,
    `user_email` varchar(255) default NULL,
    `user_post_format` varchar(5) NOT NULL default 'wiki',
    `user_edit_size` int(11) NOT NULL default '10',
    `user_pref_cat` int(11) default NULL,
    `user_lang` char(3) default NULL,
    `user_delta` int(1) NOT NULL default '0',
    `user_post_pub` int(1) NOT NULL default '0',
    PRIMARY KEY  (`user_id`)
    ) TYPE=MyISAM
  </action>
  
  <!-- CATEGORIE -->
  <action id="categorie" label="Create table %s" string="{{PREFIX}}categorie">
    <test eq="neq" value="{{PREFIX}}categorie" label="Table %s exists"
    string="{{PREFIX}}categorie">SHOW TABLES LIKE '{{PREFIX}}categorie'</test>
    
    CREATE TABLE `{{PREFIX}}categorie` (
    `cat_id` int(11) NOT NULL auto_increment,
    `cat_libelle` varchar(255) NOT NULL default '',
    `cat_desc` longtext,
    `cat_libelle_url` varchar(255) NOT NULL default '',
    `cat_ord` int(11) default NULL,
    PRIMARY KEY  (`cat_id`),
    UNIQUE KEY `cat_libelle_url` (`cat_libelle_url`),
    UNIQUE KEY `cat_libelle` (`cat_libelle`)
    ) TYPE=MyISAM
  </action>
  
  <!-- POST -->
  <action id="post" label="Create table %s" string="{{PREFIX}}post">
    <test eq="neq" value="{{PREFIX}}post" label="Table %s exists"
    string="{{PREFIX}}post">SHOW TABLES LIKE '{{PREFIX}}post'</test>
    
    CREATE TABLE `{{PREFIX}}post` (
    `post_id` int(11) NOT NULL auto_increment,
    `user_id` varchar(32) binary NOT NULL default '',
    `cat_id` int(11) default NULL,
    `post_dt` datetime default NULL,
    `post_creadt` datetime default NULL,
    `post_upddt` datetime default NULL,
    `post_titre` varchar(255) default NULL,
    `post_titre_url` varchar(255) default NULL,
    `post_chapo` longtext,
    `post_chapo_wiki` longtext,
    `post_content` longtext,
    `post_content_wiki` longtext,
    `post_notes` longtext,
    `post_pub` int(1) NOT NULL default '0',
    `post_selected` int(1) NOT NULL default '0',
    `post_open_comment` int(1) NOT NULL default '0',
    `post_open_tb` int(1) NOT NULL default '0',
    `nb_comment` int(11) NOT NULL default '0',
    `nb_trackback` int(11) NOT NULL default '0',
    `post_lang` varchar(5) default NULL,
    PRIMARY KEY  (`post_id`)
    ) TYPE=MyISAM
  </action>
  
  <!-- COMMENT -->
  <action id="comment" label="Create table %s" string="{{PREFIX}}comment">
    <test eq="neq" value="{{PREFIX}}comment" label="Table %s exists"
    string="{{PREFIX}}comment">SHOW TABLES LIKE '{{PREFIX}}comment'</test>
    
    CREATE TABLE `{{PREFIX}}comment` (
    `comment_id` int(11) NOT NULL auto_increment,
    `post_id` int(11) NOT NULL default '0',
    `comment_dt` datetime default NULL,
    `comment_upddt` datetime default NULL,
    `comment_auteur` varchar(255) default NULL,
    `comment_email` varchar(255) default NULL,
    `comment_site` varchar(255) default NULL,
    `comment_content` longtext,
    `comment_ip` varchar(15) default NULL,
    `comment_pub` int(1) default '0',
    `comment_trackback` int(1) NOT NULL default '0',
    PRIMARY KEY  (`comment_id`)
    ) TYPE=MyISAM
  </action>
  
  <!-- PING -->
  <action id="ping" label="Create table %s" string="{{PREFIX}}ping">
    <test eq="neq" value="{{PREFIX}}ping" label="Table %s exists"
    string="{{PREFIX}}ping">SHOW TABLES LIKE '{{PREFIX}}ping'</test>
    CREATE TABLE `{{PREFIX}}ping` (
    `ping_id` int(11) NOT NULL auto_increment,
    `post_id` int(11) NOT NULL default '0',
    `ping_url` varchar(255) NOT NULL default '0',
    `ping_dt` datetime default NULL,
    PRIMARY KEY  (`ping_id`)
    ) TYPE=MyISAM
  </action>
  
  <!-- LOG -->
  <action id="log" label="Create table %s" string="{{PREFIX}}log">
    <test eq="neq" value="{{PREFIX}}log" label="Table %s exists"
    string="{{PREFIX}}log">SHOW TABLES LIKE '{{PREFIX}}log'</test>
    CREATE TABLE `{{PREFIX}}log` (
    `user_id` varchar(32) binary NOT NULL default '',
    `table` varchar(255) NOT NULL default '',
    `key` varchar(255) NOT NULL default '',
    `date` datetime NOT NULL default '0000-00-00 00:00:00',
    `ip` varchar(15) default NULL,
    `log` varchar(255) NOT NULL default ''
    ) TYPE=MyISAM
  </action>
  
  <!-- LINK -->
  <action id="link" label="Create table %s" string="{{PREFIX}}link">
    <test eq="neq" value="{{PREFIX}}link" label="Table %s exists"
    string="{{PREFIX}}link">SHOW TABLES LIKE '{{PREFIX}}link'</test>
    CREATE TABLE `{{PREFIX}}link` (
    `link_id` int(11) NOT NULL auto_increment,
    `href` varchar(255) NOT NULL default '',
    `label` varchar(255) NOT NULL default '',
    `title` varchar(255) NOT NULL default '',
    `lang` char(2) NOT NULL default '',
    `rel` varchar(255) default NULL,
    `position` int(11) NOT NULL default '0',
    PRIMARY KEY  (`link_id`)
    ) TYPE=MyISAM
  </action>
  
  <!-- FULLTEXT KEYS -->
  <action id="fulltitle" label="Add fulltext key %s" string="full_post_titre">
    <test eq="eq" value="1" label="MySQL version too old" type="wrn">
    SELECT REPLACE(VERSION(),'-log','') >= '3.23.23'
    </test>
    ALTER TABLE `{{PREFIX}}post` ADD FULLTEXT `full_post_titre` (`post_titre`)
  </action>
  
  <action id="fullcontent" label="Add fulltext key %s" string="full_post_content">
    <test eq="eq" value="1" label="MySQL version too old" type="wrn">
    SELECT REPLACE(VERSION(),'-log','') >= '3.23.23'
    </test>
    ALTER TABLE `{{PREFIX}}post` ADD FULLTEXT `full_post_content` (`post_content`)
  </action>
  
  <action id="fullchapo" label="Add fulltext key %s" string="full_post_chapo">
    <test eq="eq" value="1" label="MySQL version too old" type="wrn">
    SELECT REPLACE(VERSION(),'-log','') >= '3.23.23'
    </test>
    ALTER TABLE `{{PREFIX}}post` ADD FULLTEXT `full_post_chapo` (`post_chapo`)
  </action>
  
  <!-- FIRST CATEGORY -->
  <action id="firstcat" label="Creation of first category">
  INSERT INTO `{{PREFIX}}categorie`
  (`cat_id`, `cat_libelle`, `cat_libelle_url`, `cat_ord`) VALUES
  (1, 'General', 'General', 0)
  </action>
</database>
