mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 14:39:49 -08:00
Merge pull request #11483 from snipe/fixes/migrations_on_restore
Fixes - migrations on restore
This commit is contained in:
commit
fc5cf3e291
|
@ -1278,32 +1278,28 @@ class SettingsController extends Controller
|
||||||
// If it's greater than 300, it probably worked
|
// If it's greater than 300, it probably worked
|
||||||
$output = Artisan::output();
|
$output = Artisan::output();
|
||||||
|
|
||||||
if (strlen($output) > 300) {
|
/* Run migrations */
|
||||||
$find_user = DB::table('users')->where('first_name', $user->first_name)->where('last_name', $user->last_name)->exists();
|
|
||||||
|
|
||||||
if (!$find_user){
|
|
||||||
\Log::warning('Attempting to restore user: ' . $user->first_name . ' ' . $user->last_name);
|
|
||||||
$new_user = $user->replicate();
|
|
||||||
$new_user->push();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
\Log::debug('Logging all users out..');
|
|
||||||
Artisan::call('snipeit:global-logout', ['--force' => true]);
|
|
||||||
|
|
||||||
/* run migrations */
|
|
||||||
\Log::debug('Migrating database...');
|
\Log::debug('Migrating database...');
|
||||||
Artisan::call('migrate', ['--force' => true]);
|
Artisan::call('migrate', ['--force' => true]);
|
||||||
$migrate_output = Artisan::output();
|
$migrate_output = Artisan::output();
|
||||||
\Log::debug($migrate_output);
|
\Log::debug($migrate_output);
|
||||||
|
|
||||||
|
$find_user = DB::table('users')->where('username', $user->username)->exists();
|
||||||
|
if (!$find_user){
|
||||||
|
\Log::warning('Attempting to restore user: ' . $user->username);
|
||||||
|
$new_user = $user->replicate();
|
||||||
|
$new_user->push();
|
||||||
|
} else {
|
||||||
|
\Log::debug('User: ' . $user->username .' already exists.');
|
||||||
|
}
|
||||||
|
|
||||||
|
\Log::debug('Logging all users out..');
|
||||||
|
Artisan::call('snipeit:global-logout', ['--force' => true]);
|
||||||
|
|
||||||
DB::table('users')->update(['remember_token' => null]);
|
DB::table('users')->update(['remember_token' => null]);
|
||||||
\Auth::logout();
|
\Auth::logout();
|
||||||
|
|
||||||
return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.');
|
return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.');
|
||||||
} else {
|
|
||||||
return redirect()->route('settings.backups.index')->with('error', $output);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,11 +13,13 @@ class AddEulaToCheckoutAcceptance extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
if (!Schema::hasColumn('checkout_acceptances', 'stored_eula')) {
|
||||||
Schema::table('checkout_acceptances', function (Blueprint $table) {
|
Schema::table('checkout_acceptances', function (Blueprint $table) {
|
||||||
$table->text('stored_eula')->nullable()->default(null);
|
$table->text('stored_eula')->nullable()->default(null);
|
||||||
$table->string('stored_eula_file')->nullable()->default(null);
|
$table->string('stored_eula_file')->nullable()->default(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
|
@ -26,6 +28,7 @@ class AddEulaToCheckoutAcceptance extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
|
if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) {
|
||||||
Schema::table('checkout_acceptances', function (Blueprint $table) {
|
Schema::table('checkout_acceptances', function (Blueprint $table) {
|
||||||
if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) {
|
if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) {
|
||||||
$table->dropColumn('stored_eula');
|
$table->dropColumn('stored_eula');
|
||||||
|
@ -35,4 +38,5 @@ class AddEulaToCheckoutAcceptance extends Migration
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue