fix installing failed when already installed incompletely

This commit is contained in:
printempw 2016-12-31 16:43:23 +08:00
parent d622e455c7
commit 47b0b17c15
2 changed files with 17 additions and 8 deletions

View File

@ -131,21 +131,30 @@ class SetupController extends Controller
/** /**
* Check if the given tables exist in current database. * Check if the given tables exist in current database.
* *
* @param array $tables [description] * @param array $tables
* @return bool * @return bool
*/ */
public static function checkTablesExist($tables = [ public static function checkTablesExist($tables = [
'users', 'closets', 'players', 'textures', 'options' 'users', 'closets', 'players', 'textures', 'options'
]) ]) {
{ $totalTables = 0;
foreach ($tables as $table_name) {
foreach ($tables as $tableName) {
// prefix will be added automatically // prefix will be added automatically
if (!Schema::hasTable($table_name)) { if (Schema::hasTable($tableName)) {
return false; $totalTables++;
} }
} }
return true; if ($totalTables == count($tables)) {
return true;
} else {
// not installed completely
foreach (array_merge($tables, ['migrations']) as $tableName) {
Schema::dropIfExists($tableName);
}
return false;
}
} }
public static function checkTextureDirectory() public static function checkTextureDirectory()

View File

@ -54,4 +54,4 @@ wizard:
finish: finish:
title: 安装成功! title: 安装成功!
success: Blessing Skin Server 安装完成。您是否还沉浸在愉悦的安装过程中?很遗憾,一切皆已完成! :) text: Blessing Skin Server 安装完成。您是否还沉浸在愉悦的安装过程中?很遗憾,一切皆已完成! :)