SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE `abonnements` (
  `journal` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_check` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `abonnements_queue` (
  `journal` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ecrit` int(10) UNSIGNED NOT NULL,
  `date` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `acces_prives` (
  `id` int(11) NOT NULL,
  `membre` int(11) DEFAULT NULL,
  `journal` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `login` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ecrits` (
  `id` int(11) NOT NULL,
  `journal` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `titre` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` int(20) DEFAULT NULL,
  `ip` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mois` int(6) NOT NULL DEFAULT '0',
  `uri` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ecrits_html` (
  `id` int(11) NOT NULL DEFAULT '0',
  `texte` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `forums` (
  `id` int(11) NOT NULL,
  `journal` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nom` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `titre` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` int(20) DEFAULT NULL,
  `parent` int(11) NOT NULL DEFAULT '0',
  `dernier_message` int(20) DEFAULT NULL,
  `ip` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reponses` int(3) NOT NULL DEFAULT '0',
  `uri` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `forums_textes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `texte` text COLLATE utf8mb4_unicode_ci
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journaux` (
  `id` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `auteur` int(11) NOT NULL DEFAULT '0',
  `titre` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `texte` text COLLATE utf8mb4_unicode_ci,
  `statut` tinyint(4) NOT NULL DEFAULT '0',
  `forum` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
  `abonnement` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
  `contact` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
  `print` int(11) NOT NULL DEFAULT '0',
  `dernier` int(11) NOT NULL DEFAULT '0',
  `visuel` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `force_private` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `notifications` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `membres` (
  `id` int(11) NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `date` int(20) DEFAULT NULL,
  `ip` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `courant` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `timezone` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `date_inscription` int(11) NOT NULL DEFAULT '0',
  `ip_inscription` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `banned` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `session_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `admin` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `user_secret_keys` (
  `key` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `action` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
  `expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `content` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


ALTER TABLE `abonnements`
  ADD UNIQUE KEY `journal` (`journal`,`email`);

ALTER TABLE `abonnements_queue`
  ADD PRIMARY KEY (`ecrit`);

ALTER TABLE `acces_prives`
  ADD PRIMARY KEY (`id`),
  ADD KEY `membre` (`membre`,`journal`),
  ADD KEY `journal` (`journal`,`login`,`password`);

ALTER TABLE `ecrits`
  ADD PRIMARY KEY (`id`),
  ADD KEY `journal` (`journal`),
  ADD KEY `mois` (`mois`),
  ADD KEY `uri` (`uri`),
  ADD KEY `status` (`status`),
  ADD KEY `date` (`date`);

ALTER TABLE `ecrits_html`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `ecrits_html` ADD FULLTEXT KEY `texte` (`texte`);

ALTER TABLE `forums`
  ADD PRIMARY KEY (`id`),
  ADD KEY `journal` (`journal`),
  ADD KEY `parent` (`parent`),
  ADD KEY `ip` (`ip`);

ALTER TABLE `forums_textes`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `journaux`
  ADD PRIMARY KEY (`id`),
  ADD KEY `statut` (`statut`),
  ADD KEY `auteur` (`auteur`),
  ADD KEY `force_private` (`force_private`);

ALTER TABLE `membres`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`),
  ADD KEY `date` (`date`),
  ADD KEY `session_id` (`session_id`);

ALTER TABLE `user_secret_keys`
  ADD PRIMARY KEY (`key`),
  ADD KEY `action` (`action`,`user_id`,`expires`);


ALTER TABLE `acces_prives`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `ecrits`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `forums`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `membres`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;