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(redis): set default redis_username for new instances

Andras Bacsai282bb5c4cdcc
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index ed5cf98708..6037364fe7 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -38,6 +38,12 @@ class StandaloneRedis extends BaseModel
$database->forceFill(['last_online_at' => now()]);
}
});
+
+ static::retrieved(function ($database) {
+ if (! $database->redis_username) {
+ $database->redis_username = 'default';
+ }
+ });
}
protected function serverStatus(): Attribute
@@ -193,8 +199,8 @@ class StandaloneRedis extends BaseModel
{
return Attribute::make(
get: fn () => is_null($this->ports_mappings)
- ? []
- : explode(',', $this->ports_mappings),
+ ? []
+ : explode(',', $this->ports_mappings),
);
}
@@ -346,7 +352,12 @@ class StandaloneRedis extends BaseModel
get: function () {
$username = $this->runtime_environment_variables()->where('key', 'REDIS_USERNAME')->first();
if (! $username) {
- return null;
+ $this->runtime_environment_variables()->create([
+ 'key' => 'REDIS_USERNAME',
+ 'value' => 'default',
+ ]);
+
+ return 'default';
}
return $username->value;