Merge pull request #5502 from lwj5/db

Allow use of `DB_DATABASE` without 1 prefix
This commit is contained in:
David Bomba 2021-04-24 23:28:07 +10:00 committed by GitHub
commit 85f12eb871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 29 deletions

View File

@ -47,8 +47,9 @@ class SetupController extends Controller
{ {
$check = SystemHealth::check(false); $check = SystemHealth::check(false);
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) {
return redirect('/'); return redirect('/');
}
// not sure if we really need this. // not sure if we really need this.
// if(File::exists(base_path('.env'))) // if(File::exists(base_path('.env')))
@ -124,9 +125,12 @@ class SetupController extends Controller
'MAIL_PASSWORD' => $request->input('mail_password'), 'MAIL_PASSWORD' => $request->input('mail_password'),
'NINJA_ENVIRONMENT' => 'selfhost', 'NINJA_ENVIRONMENT' => 'selfhost',
'DB_CONNECTION' => 'db-ninja-01',
]; ];
if (config('ninja.db.multi_db_enabled')) {
$env_values['DB_CONNECTION'] = 'db-ninja-01';
}
if (config('ninja.preconfigured_install')) { if (config('ninja.preconfigured_install')) {
// Database connection was already configured. Don't let the user override it. // Database connection was already configured. Don't let the user override it.
unset($env_values['DB_HOST1']); unset($env_values['DB_HOST1']);
@ -137,7 +141,6 @@ class SetupController extends Controller
} }
try { try {
foreach ($env_values as $property => $value) { foreach ($env_values as $property => $value) {
$this->updateEnvironmentProperty($property, $value); $this->updateEnvironmentProperty($property, $value);
} }
@ -149,8 +152,9 @@ class SetupController extends Controller
DB::purge('db-ninja-01'); DB::purge('db-ninja-01');
/* Run migrations */ /* Run migrations */
if(!config('ninja.disable_auto_update')) if (!config('ninja.disable_auto_update')) {
Artisan::call('optimize'); Artisan::call('optimize');
}
Artisan::call('migrate', ['--force' => true]); Artisan::call('migrate', ['--force' => true]);
Artisan::call('db:seed', ['--force' => true]); Artisan::call('db:seed', ['--force' => true]);
@ -168,7 +172,6 @@ class SetupController extends Controller
return redirect('/'); return redirect('/');
} catch (Exception $e) { } catch (Exception $e) {
nlog($e->getMessage()); nlog($e->getMessage());
info($e->getMessage()); info($e->getMessage());
@ -278,9 +281,13 @@ class SetupController extends Controller
return redirect('/'); return redirect('/');
$cacheCompiled = base_path('bootstrap/cache/compiled.php'); $cacheCompiled = base_path('bootstrap/cache/compiled.php');
if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); } if (file_exists($cacheCompiled)) {
unlink ($cacheCompiled);
}
$cacheServices = base_path('bootstrap/cache/services.php'); $cacheServices = base_path('bootstrap/cache/services.php');
if (file_exists($cacheServices)) { unlink ($cacheServices); } if (file_exists($cacheServices)) {
unlink ($cacheServices);
}
Artisan::call('clear-compiled'); Artisan::call('clear-compiled');
Artisan::call('cache:clear'); Artisan::call('cache:clear');

View File

@ -13,7 +13,7 @@ return [
| |
*/ */
'default' => env('DB_CONNECTION', 'db-ninja-01'), 'default' => env('DB_CONNECTION', 'mysql'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -36,14 +36,15 @@ return [
// single database setup // single database setup
'mysql' => [ 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => env('DB_HOST1', '127.0.0.1'), 'host' => env('DB_HOST1', env('DB_HOST', '127.0.0.1')),
'database' => env('DB_DATABASE1', 'forge'), 'database' => env('DB_DATABASE1', env('DB_DATABASE', 'forge')),
'username' => env('DB_USERNAME1', 'forge'), 'username' => env('DB_USERNAME1', env('DB_USERNAME', 'forge')),
'password' => env('DB_PASSWORD1', ''), 'password' => env('DB_PASSWORD1', env('DB_PASSWORD', '')),
'port' => env('DB_PORT1', '3306'), 'port' => env('DB_PORT1', env('DB_PORT', '3306')),
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',
'prefix_indexes' => true,
'strict' => env('DB_STRICT', false), 'strict' => env('DB_STRICT', false),
'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8',
], ],