Skip to content

Commit

Permalink
Merge pull request #1595 from Marc-pi/develop
Browse files Browse the repository at this point in the history
Add InnoDB migration tool
  • Loading branch information
Marc-pi authored May 29, 2018
2 parents 2607fbf + e63e2ed commit ce33319
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
19 changes: 18 additions & 1 deletion usr/module/system/src/Controller/Admin/DatabaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function checkAction()

$tablesError = [];
$columnsError = [];
$innodbError = [];

foreach ($results->toArray() as $result) {
$tableName = array_shift($result);
Expand All @@ -44,10 +45,13 @@ public function checkAction()


foreach ($res->toArray() as $params) {

if ($params['Collation'] && $params['Collation'] != 'utf8_general_ci') {
$tablesError[$tableName] = $params['Collation'];
}

if ($params['Engine'] && $params['Engine'] != 'InnoDB') {
$innodbError[$tableName] = $params['Engine'];
}
}

$sql
Expand All @@ -66,5 +70,18 @@ public function checkAction()

$this->view()->assign('columnsError', $columnsError);
$this->view()->assign('tablesError', $tablesError);
$this->view()->assign('innodbError', $innodbError);
}

public function migrateAction()
{
$table = $this->params('table');

if($table){
$sql = "ALTER TABLE $table ENGINE=InnoDB;";
Pi::db()->getAdapter()->query($sql, 'execute');
}

$this->redirect()->toRoute('', ['action' => 'check']);
}
}
18 changes: 16 additions & 2 deletions usr/module/system/template/admin/database-check.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
</div>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<?php echo _a('Results for tables'); ?>
Expand All @@ -25,7 +25,7 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<?php echo _a('Results for columns'); ?>
Expand All @@ -35,5 +35,19 @@
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<?php echo _a('Results for InnoDB check'); ?>
</div>
<div class="panel-body">
<ul>
<?php foreach($innodbError as $tableName => $tableType) : ?>
<li><?php echo $tableName ?> (<?php echo $tableType ?>) => <a href="<?php echo $this->url('', ['action' => 'migrate']); ?>?table=<?php echo $tableName ?>">InnoDB</a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion usr/module/system/template/admin/database-index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="col-md-3 text-right">
<a href="<?php echo $this->url('', ['action' => 'check']); ?>" class="btn btn-primary btn-sm">
<i class="fa fa-cog" aria-hidden="true"></i>
<?php echo _a('Check UTF8'); ?>
<?php echo _a('Check UTF8 and Innodb'); ?>
</a>
</div>
</div>
Expand Down

0 comments on commit ce33319

Please sign in to comment.