Check for InnoDB engine

This commit is contained in:
Hillel Coren 2017-03-09 21:43:53 +02:00
parent efc226c23d
commit e08f583c3a
2 changed files with 16 additions and 2 deletions

View File

@ -268,6 +268,7 @@ class AppController extends BaseController
if (! Utils::isNinjaProd()) {
try {
set_time_limit(60 * 5);
$this->checkInnoDB();
Artisan::call('clear-compiled');
Artisan::call('cache:clear');
Artisan::call('debugbar:clear');
@ -303,6 +304,21 @@ class AppController extends BaseController
return Redirect::to('/');
}
// MySQL changed the default table type from MyISAM to InnoDB
// We need to make sure all tables are InnoDB to prevent migration failures
public function checkInnoDB()
{
$tables = DB::select('SHOW TABLES');
$sql = "SET sql_mode = 'ALLOW_INVALID_DATES';\n";
foreach($tables as $table) {
$fieldName = 'Tables_in_' . env('DB_DATABASE');
$sql .= "ALTER TABLE {$table->$fieldName} engine=InnoDB;\n";
}
DB::unprepared($sql);
}
public function emailBounced()
{
$messageId = Input::get('MessageID');

View File

@ -14,8 +14,6 @@ If the auto-update fails you can manually run the update with the following comm
php artisan migrate
php artisan db:seed --class=UpdateSeeder
Weve seen some updates fail when moving the app to a new server because the MySQL default storage engine has changed with MySQL 5.7. If you see ``SQLSTATE[HY000]: General error: 1215`` error you may be able to fix it by running this `SQL query <https://www.invoiceninja.com/forums/topic/problem-with-new-install/#post-5313>`_
Version 2.6
"""""""""""