Add integrity check for new columns in users table
This commit is contained in:
parent
3c840aca46
commit
6cb200bc39
|
|
@ -193,7 +193,8 @@ class SetupController extends Controller
|
||||||
* @param bool $returnExisting
|
* @param bool $returnExisting
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
*/
|
*/
|
||||||
public static function checkTablesExist($tables = [], $returnExistingTables = false) {
|
public static function checkTablesExist($tables = [], $returnExistingTables = false)
|
||||||
|
{
|
||||||
$existingTables = [];
|
$existingTables = [];
|
||||||
$tables = $tables ?: ['users', 'closets', 'players', 'textures', 'options'];
|
$tables = $tables ?: ['users', 'closets', 'players', 'textures', 'options'];
|
||||||
|
|
||||||
|
|
@ -211,6 +212,28 @@ class SetupController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given columns exist in specific table.
|
||||||
|
* By default, we will check the columns newly added to users table in BS v3.5.0.
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param array $columns
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function checkNewColumnsExist($table = 'users', $columns = [])
|
||||||
|
{
|
||||||
|
$existingColumns = [];
|
||||||
|
$columns = $columns ?: ['verified', 'verification_token'];
|
||||||
|
|
||||||
|
foreach ($columns as $column) {
|
||||||
|
if (Schema::hasColumn($table, $column)) {
|
||||||
|
$existingColumns[] = $column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count($existingColumns) === count($columns);
|
||||||
|
}
|
||||||
|
|
||||||
public static function checkDirectories()
|
public static function checkDirectories()
|
||||||
{
|
{
|
||||||
$directories = ['storage/textures', 'plugins'];
|
$directories = ['storage/textures', 'plugins'];
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
|
use Schema;
|
||||||
|
use Artisan;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Composer\Semver\Comparator;
|
use Composer\Semver\Comparator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
@ -89,6 +91,13 @@ class RuntimeCheckServiceProvider extends ServiceProvider
|
||||||
return redirect('/setup/update')->send();
|
return redirect('/setup/update')->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! SetupController::checkNewColumnsExist()) {
|
||||||
|
// Disable the email verification feature temporarily
|
||||||
|
option(['require_verification' => false]);
|
||||||
|
// Try to prepare the new columns
|
||||||
|
Artisan::call('migrate', ['--force' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,7 @@ wizard:
|
||||||
finish:
|
finish:
|
||||||
title: Installation complete
|
title: Installation complete
|
||||||
text: Blessing Skin Server has been installed. Thank you, and enjoy!
|
text: Blessing Skin Server has been installed. Thank you, and enjoy!
|
||||||
|
|
||||||
|
integrity-check:
|
||||||
|
title: We could not complete the installation.
|
||||||
|
description: The automatic upgrade script failed to update your database. <a target="_blank" href="https://github.com/printempw/blessing-skin-server/wiki/%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85-Blessing-Skin#-%E5%8D%87%E7%BA%A7%E8%87%B3-bs-v350">Learn more</a>
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,7 @@ wizard:
|
||||||
finish:
|
finish:
|
||||||
title: 安装成功!
|
title: 安装成功!
|
||||||
text: Blessing Skin Server 安装完成。您是否还沉浸在愉悦的安装过程中?很遗憾,一切皆已完成! :)
|
text: Blessing Skin Server 安装完成。您是否还沉浸在愉悦的安装过程中?很遗憾,一切皆已完成! :)
|
||||||
|
|
||||||
|
integrity-check:
|
||||||
|
title: 安装不完全
|
||||||
|
description: 由于某些神秘的原因,我们无法自动完成数据库的更新。<a target="_blank" href="https://github.com/printempw/blessing-skin-server/wiki/%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85-Blessing-Skin#-%E5%8D%87%E7%BA%A7%E8%87%B3-bs-v350">了解详情</a>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,13 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
@if (! App\Http\Controllers\SetupController::checkNewColumnsExist())
|
||||||
|
<div class="callout callout-danger">
|
||||||
|
<h4><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> {{ trans('setup.integrity-check.title') }}</h4>
|
||||||
|
<p>{!! trans('setup.integrity-check.description') !!}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
{!! $forms['general']->render() !!}
|
{!! $forms['general']->render() !!}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user