Changing MySQL / MariaDB engine to InnoDB, Fixes #121

This commit is contained in:
Benjamin Sonntag 2017-06-17 21:27:12 +02:00
parent 47e689adf6
commit 1c08a3e5a0
2 changed files with 72 additions and 44 deletions

View File

@ -1,7 +1,7 @@
--
-- ----------------------------------------------------------------------
-- AlternC - Web Hosting System
-- Copyright (C) 2000-2012 by the AlternC Development Team.
-- Copyright (C) 2000-2017 by the AlternC Development Team.
-- https://alternc.org/
-- ----------------------------------------------------------------------
-- LICENSE
@ -23,26 +23,26 @@
--
-- ----------------------------------------------------------------------
-- STRUCTURE DES TABLES D`ALTERNC
-- AlternC's table structure
--
-- IMPORTANT: lorsque la structure de ces tables est modifiée, le
-- fichier upgrades/<version>.sql doit être modifié (ou créé!) pour que
-- les installations courantes soient mises à jour. <version> est ici
-- le prochain numéro de version d`AlternC. Voir upgrades/README pour
-- plus de détails.
-- WARNING: when you change anything here,
-- the upgrades/<version>.sql file must be edited or created
-- so that already running alternc instances can be upgraded.
-- <version> must be higher than previous version
-- See upgrades/README for more information.
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `slaveip` (
`ip` VARCHAR( 40 ) NOT NULL ,
`class` TINYINT NOT NULL ,
PRIMARY KEY ( `ip` , `class` )
) ENGINE=MyISAM COMMENT = 'Allowed ip for slave dns managment';
) ENGINE=InnoDB COMMENT = 'Allowed ip for slave dns managment';
CREATE TABLE IF NOT EXISTS `slaveaccount` (
`login` VARCHAR( 64 ) NOT NULL ,
`pass` VARCHAR( 64 ) NOT NULL ,
PRIMARY KEY ( `login` )
) ENGINE=MyISAM COMMENT = 'Allowed account for slave dns managment';
) ENGINE=InnoDB COMMENT = 'Allowed account for slave dns managment';
--
@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS browser (
golastdir tinyint(4) NOT NULL default '0', -- Faut-il aller au dernier dossier ou au dossier racine dans le brouteur ?
lastdir varchar(255) NOT NULL default '', -- Dernier dossier visité.
PRIMARY KEY (uid)
) ENGINE=MyISAM COMMENT='Préférences du gestionnaire de fichiers';
) ENGINE=InnoDB COMMENT='Préférences du gestionnaire de fichiers';
--
@ -81,7 +81,7 @@ CREATE TABLE IF NOT EXISTS chgmail (
mail varchar(128) NOT NULL default '', -- Nouvel Email
ts bigint(20) unsigned NOT NULL default '0', -- Timestamp de la demande
PRIMARY KEY (uid)
) ENGINE=MyISAM COMMENT='Demandes de changements de mail en cours';
) ENGINE=InnoDB COMMENT='Demandes de changements de mail en cours';
--
-- Structure de la table `db`
@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS db (
bck_gzip tinyint(3) unsigned NOT NULL default '0', -- Faut-il compresser les backups ?
bck_dir varchar(255) NOT NULL default '', -- Où stocke-t-on les backups sql ?
PRIMARY KEY id (id)
) ENGINE=MyISAM COMMENT='Bases MySQL des membres';
) ENGINE=InnoDB COMMENT='Bases MySQL des membres';
--
-- Structure de la table `domaines`
@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS domaines (
zonettl int(10) unsigned NOT NULL default '86400',
PRIMARY KEY (id),
UNIQUE KEY (domaine)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
--
-- Structure de la table `ftpusers`
@ -137,7 +137,7 @@ CREATE TABLE IF NOT EXISTS ftpusers (
UNIQUE KEY name (name),
KEY homedir (homedir),
KEY mid (uid)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
--
-- Structure de la table `local`
@ -149,7 +149,7 @@ CREATE TABLE IF NOT EXISTS local (
nom varchar(128) NOT NULL default '',
prenom varchar(128) NOT NULL default '',
PRIMARY KEY (uid)
) ENGINE=MyISAM COMMENT='Parametres Locaux des membres';
) ENGINE=InnoDB COMMENT='Parametres Locaux des membres';
--
-- Structure de la table `membres`
@ -181,7 +181,7 @@ CREATE TABLE IF NOT EXISTS membres (
duration int(4) default NULL,
PRIMARY KEY (uid),
UNIQUE KEY k_login (login)
) ENGINE=MyISAM COMMENT='Liste des membres du serveur';
) ENGINE=InnoDB COMMENT='Liste des membres du serveur';
--
-- Structure de la table `quotas`
@ -193,7 +193,7 @@ CREATE TABLE IF NOT EXISTS quotas (
name varchar(64) NOT NULL default '', -- Nom du quota
total bigint(20) unsigned NOT NULL default '0', -- Quota total (maximum autorisé)
PRIMARY KEY (uid,name)
) ENGINE=MyISAM COMMENT='Quotas des Membres';
) ENGINE=InnoDB COMMENT='Quotas des Membres';
--
-- Structure de la table `sessions`
@ -205,7 +205,7 @@ CREATE TABLE IF NOT EXISTS sessions (
uid int(10) unsigned NOT NULL default '0', -- UID du membre concerné
ip varchar(40) NOT NULL default '', -- Adresse IP de la connexion
ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=MyISAM COMMENT='Session actives sur le bureau';
) ENGINE=InnoDB COMMENT='Session actives sur le bureau';
--
-- Structure de la table `sub_domaines`
@ -224,7 +224,7 @@ CREATE TABLE IF NOT EXISTS sub_domaines (
enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED',
PRIMARY KEY (id)
-- ,FOREIGN KEY (type) REFERENCES (domaines_type)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
--
-- Main address table.
@ -243,7 +243,7 @@ CREATE TABLE IF NOT EXISTS `address` (
`mail_action` enum('OK','DELETE','DELETING') NOT NULL default 'OK', -- mail_action is DELETE or DELETING when deleting a mailbox by cron
PRIMARY KEY (`id`),
UNIQUE INDEX `fk_domain_id` (`domain_id`,`address`)
) ENGINE=MyISAM COMMENT = 'This is the main address table. It represents an address as in RFC2822';
) ENGINE=InnoDB COMMENT = 'This is the main address table. It represents an address as in RFC2822';
--
-- Mailbox table.
@ -263,7 +263,7 @@ CREATE TABLE IF NOT EXISTS `mailbox` (
`mail_action` enum('OK','DELETE','DELETING') NOT NULL default 'OK', -- mail_action is DELETE or DELETING when deleting a mailbox by cron
PRIMARY KEY (`id`),
UNIQUE KEY `address_id` (`address_id`)
) ENGINE=MyISAM COMMENT = 'Table containing local deliverd mailboxes.';
) ENGINE=InnoDB COMMENT = 'Table containing local deliverd mailboxes.';
--
-- Other recipients.
@ -277,7 +277,7 @@ CREATE TABLE IF NOT EXISTS `recipient` (
`update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Update date, for technical usage only.
PRIMARY KEY (`id`),
UNIQUE KEY `key_id` (`id`,`address_id`)
) ENGINE=MyISAM COMMENT = 'Table containing other recipients (aliases) for an address.';
) ENGINE=InnoDB COMMENT = 'Table containing other recipients (aliases) for an address.';
--
@ -290,7 +290,7 @@ CREATE TABLE IF NOT EXISTS defquotas (
value bigint(20) unsigned default '0', -- Valeur du quota
type varchar(128) default 'default', -- Type de compte associée à ce quota
PRIMARY KEY (quota,type)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
--
-- Quotas par defaut pour les nouveaux membres
@ -313,7 +313,7 @@ INSERT IGNORE INTO defquotas (quota,value) VALUES ('mysql',1);
CREATE TABLE IF NOT EXISTS forbidden_domains (
domain varchar(255) NOT NULL default '',
PRIMARY KEY (domain)
) ENGINE=MyISAM COMMENT='forbidden domains to install';
) ENGINE=InnoDB COMMENT='forbidden domains to install';
--
-- Contenu de la table `forbidden_domains`
@ -356,7 +356,7 @@ CREATE TABLE IF NOT EXISTS tld (
mode tinyint(4) NOT NULL default '0', -- Comment est-il autorisé ?
PRIMARY KEY (tld),
KEY mode (mode)
) ENGINE=MyISAM COMMENT='TLD autorises et comment sont-ils autorises ? ';
) ENGINE=InnoDB COMMENT='TLD autorises et comment sont-ils autorises ? ';
--
-- Contenu de la table `tld`
@ -393,7 +393,7 @@ CREATE TABLE IF NOT EXISTS `variable` (
`type` text,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM COMMENT='Stores AlternC system variable used by panel and scripts, configurable through the panel';
) ENGINE=InnoDB COMMENT='Stores AlternC system variable used by panel and scripts, configurable through the panel';
--
-- Table structure for table `dbusers`
@ -406,14 +406,14 @@ CREATE TABLE IF NOT EXISTS `dbusers` (
`password` varchar( 64 ),
`enable` enum ('ACTIVATED', 'HIDDEN', 'ADMIN') NOT NULL DEFAULT 'ACTIVATED',
KEY `id` (`id`)
) ENGINE=MyISAM COMMENT='Utilisateurs MySQL des membres';
) ENGINE=InnoDB COMMENT='Utilisateurs MySQL des membres';
CREATE TABLE IF NOT EXISTS `mxaccount` (
`login` VARCHAR( 64 ) NOT NULL ,
`pass` VARCHAR( 64 ) NOT NULL ,
PRIMARY KEY ( `login` )
) ENGINE=MyISAM COMMENT = 'Allowed account for secondary mx managment';
) ENGINE=InnoDB COMMENT = 'Allowed account for secondary mx managment';
-- --------------------------------------------------------
@ -423,7 +423,7 @@ CREATE TABLE IF NOT EXISTS `size_web` (
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`uid`),
KEY `ts` (`ts`)
) ENGINE=MyISAM COMMENT='Web space used by accounts.';
) ENGINE=InnoDB COMMENT='Web space used by accounts.';
-- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `size_db` (
@ -432,7 +432,7 @@ CREATE TABLE IF NOT EXISTS `size_db` (
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`db`),
KEY `ts` (`ts`)
) ENGINE=MyISAM COMMENT='MySQL Database used space';
) ENGINE=InnoDB COMMENT='MySQL Database used space';
-- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `size_mailman` (
@ -443,7 +443,7 @@ CREATE TABLE IF NOT EXISTS `size_mailman` (
PRIMARY KEY (`list`),
KEY `ts` (`ts`),
KEY `uid` (`uid`)
) ENGINE=MyISAM COMMENT='Mailman Lists used space';
) ENGINE=InnoDB COMMENT='Mailman Lists used space';
-- --------------------------------------------------------
@ -455,7 +455,7 @@ CREATE TABLE IF NOT EXISTS `policy` (
`classcount` tinyint(3) unsigned NOT NULL,
`allowlogin` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='The password policies for services';
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='The password policies for services';
-- Domains type
CREATE TABLE IF NOT EXISTS `domaines_type` (
@ -471,7 +471,7 @@ CREATE TABLE IF NOT EXISTS `domaines_type` (
`create_tmpdir` BOOLEAN NOT NULL DEFAULT FALSE, -- do we create tmp dir ?
`create_targetdir` BOOLEAN NOT NULL DEFAULT FALSE, -- do we create target dir ?
PRIMARY KEY ( `name` )
) ENGINE=MyISAM COMMENT = 'Type of domains allowed';
) ENGINE=InnoDB COMMENT = 'Type of domains allowed';
INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced, enable) values
('vhost', 'Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt,defmx,defmx2,mx,mx2', false, false, false, 'ALL'),
@ -553,7 +553,7 @@ CREATE TABLE IF NOT EXISTS `authorised_ip` (
`infos` varchar(255) not null default '',
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=MyISAM COMMENT='Table with list of authorised ip and subnet';
) ENGINE=InnoDB COMMENT='Table with list of authorised ip and subnet';
-- Who have authorised IP ?
CREATE TABLE IF NOT EXISTS `authorised_ip_affected` (
@ -562,7 +562,7 @@ CREATE TABLE IF NOT EXISTS `authorised_ip_affected` (
`protocol` varchar(15) not null,
`parameters` varchar(30) default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM COMMENT='Table with list of protocol <-> authorised ip and subnet';
) ENGINE=InnoDB COMMENT='Table with list of protocol <-> authorised ip and subnet';
--
-- Structure de la table `cron`
@ -579,7 +579,7 @@ CREATE TABLE IF NOT EXISTS `cron` (
`next_execution` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@ -665,7 +665,7 @@ CREATE TABLE IF NOT EXISTS `piwik_users` (
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_user` (`login`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
--
-- Structure de la table `piwik_sites`
@ -677,7 +677,7 @@ CREATE TABLE IF NOT EXISTS `piwik_sites` (
`piwik_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_site_per_user` (`uid`,`piwik_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- Defaults subdomains to create when a domain is added
CREATE TABLE IF NOT EXISTS `default_subdomains` (
@ -689,7 +689,7 @@ CREATE TABLE IF NOT EXISTS `default_subdomains` (
`enabled` boolean not null default true,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_row` (`sub`,`domain_type`,`domain_type_parameter`,`concerned`)
) ENGINE=MyISAM COMMENT='Contains the defaults subdomains created on domains creation';
) ENGINE=InnoDB COMMENT='Contains the defaults subdomains created on domains creation';
INSERT IGNORE INTO `default_subdomains` (`sub`, `domain_type`, `domain_type_parameter`, `concerned`) VALUES
('www', 'VHOST', '%%DOMAINDIR%%', 'MAIN'),
@ -709,7 +709,7 @@ CREATE TABLE IF NOT EXISTS `db_servers` (
`password` varchar(255) NOT NULL,
`client` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM COMMENT='List of the databases servers';
) ENGINE=InnoDB COMMENT='List of the databases servers';
-- Table for VM requests
CREATE TABLE IF NOT EXISTS `vm_history` (
@ -722,7 +722,7 @@ CREATE TABLE IF NOT EXISTS `vm_history` (
PRIMARY KEY (`id`),
KEY `date_end` (`date_end`),
KEY `uid` (`uid`)
) ENGINE=MyISAM COMMENT='VM Allocation requests';
) ENGINE=InnoDB COMMENT='VM Allocation requests';
CREATE TABLE IF NOT EXISTS `actions` (
@ -735,17 +735,17 @@ CREATE TABLE IF NOT EXISTS `actions` (
user varchar(255) default NULL,
status int(8) unsigned default NULL,
PRIMARY KEY ( `id` )
) ENGINE=MyISAM COMMENT = 'generic actions';
) ENGINE=InnoDB COMMENT = 'generic actions';
-- version control now in MySQL
CREATE TABLE IF NOT EXISTS `alternc_status` (
`name` varchar(48) NOT NULL DEFAULT '',
`value` longtext NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT = 'stores current AlternC schema version number';
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT = 'stores current AlternC schema version number';
-- make it re-exec-proof
DELETE FROM alternc_status WHERE name='alternc_version';
INSERT INTO alternc_status SET name='alternc_version',value='3.4.1.sh';
INSERT INTO alternc_status SET name='alternc_version',value='3.4.7.php';

View File

@ -0,0 +1,28 @@
#!/usr/bin/php
<?php
// We check that mysql php module is loaded
if(!function_exists('mysql_connect')) {
if(!dl("mysql.so"))
exit(1);
}
// we don't check our AlternC session
if(!chdir("/usr/share/alternc/panel"))
exit(1);
require("/usr/share/alternc/panel/class/config_nochk.php");
// we enumerate all tables in AlternC's database, and change (if necessary) their engine to InnoDB
$tables=array();
$db->query("SHOW TABLES;");
while ($db->next_record()) {
$tables[]=$db->Record[0];
}
echo "Setting AlternC's tables to InnoDB engine\n";
foreach($tables as $table) {
$db->query("ALTER TABLE `".$table."` ENGINE InnoDB;");
}
echo "Done\n";