Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: encrypt all existing redis passwords

peaklabs-dev287714503216
diff --git a/database/migrations/2024_10_16_120026_encrypt_existing_redis_passwords.php b/database/migrations/2024_10_16_120026_encrypt_existing_redis_passwords.php
new file mode 100644
index 0000000000..3b4f11986f
--- /dev/null
+++ b/database/migrations/2024_10_16_120026_encrypt_existing_redis_passwords.php
@@ -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();
+ }
+ }
+}