fix: encrypt all existing redis passwords
This commit is contained in:
parent
85c3270dcc
commit
2877145032
1 changed files with 27 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EncryptExistingRedisPasswords extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
DB::table('standalone_redis')->chunkById(100, function ($redisInstances) {
|
||||
foreach ($redisInstances as $redis) {
|
||||
DB::table('standalone_redis')
|
||||
->where('id', $redis->id)
|
||||
->update(['redis_password' => Crypt::encryptString($redis->redis_password)]);
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Encrypting Redis passwords failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue