Merge branch 'next' into improve-cleanup
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateServerSettingsDefaultTimezone extends Migration
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EncryptExistingPrivateKeys extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
try {
|
||||
DB::table('private_keys')->chunkById(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
DB::table('private_keys')
|
||||
->where('id', $key->id)
|
||||
->update(['private_key' => Crypt::encryptString($key->private_key)]);
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Encrypting private keys failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddSshKeyFingerprintToPrivateKeysTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('private_keys', function (Blueprint $table) {
|
||||
$table->string('fingerprint')->after('private_key')->nullable();
|
||||
});
|
||||
|
||||
try {
|
||||
DB::table('private_keys')->chunkById(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
$fingerprint = PrivateKey::generateFingerprint($key->private_key);
|
||||
if ($fingerprint) {
|
||||
$key->fingerprint = $fingerprint;
|
||||
$key->save();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Generating fingerprints failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('private_keys', function (Blueprint $table) {
|
||||
$table->dropColumn('fingerprint');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user