MDL-31165 fix InnoDB conversion query to use ENGINE parameter instead of legacy TYPE
[moodle.git] / admin / tool / innodb / index.php
CommitLineData
72941d56
PS
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * InnoDB conversion tool.
19 *
20 * @package tool
21 * @subpackage innodb
22 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26define('NO_OUTPUT_BUFFERING', true);
27
28require_once('../../../config.php');
29require_once($CFG->libdir.'/adminlib.php');
30
31admin_externalpage_setup('toolinnodb');
32
33$confirm = optional_param('confirm', 0, PARAM_BOOL);
34
35require_login();
36require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
37
38echo $OUTPUT->header();
39echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
40
41if ($DB->get_dbfamily() != 'mysql') {
42 notice('This function is for MySQL databases only!', new moodle_url('/admin/'));
43}
44
45if (data_submitted() and $confirm and confirm_sesskey()) {
46
47 echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
48
49 if ($tables = $DB->get_tables()) {
50 $DB->set_debug(true);
51 foreach ($tables as $table) {
52 $fulltable = $DB->get_prefix().$table;
5f0456ef 53 $DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB");
72941d56
PS
54 }
55 $DB->set_debug(false);
56 }
57 echo $OUTPUT->notification('... done.', 'notifysuccess');
58 echo $OUTPUT->continue_button(new moodle_url('/admin/'));
59 echo $OUTPUT->footer();
60
61} else {
62 $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
63 $formcontinue = new single_button(new moodle_url('/admin/tool/innodb/index.php', $optionsyes), get_string('yes'));
64 $formcancel = new single_button(new moodle_url('/admin/'), get_string('no'), 'get');
65 echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel);
66 echo $OUTPUT->footer();
67}
68
69