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(core): v1 parser versions trying to access application_id, while it is resourceable_id fix(db): remove wrongly created, empty environmentvariables

Andras Bacsai085103708ceb
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 330f2627a7..791e2eb095 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -2645,7 +2645,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($value?->startsWith('$')) {
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
])->first();
$value = replaceVariables($value);
@@ -2653,7 +2654,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($value->startsWith('SERVICE_')) {
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
['command' => $command, 'forService' => $forService, 'generatedValue' => $generatedValue, 'port' => $port] = parseEnvVariable($value);
if (! is_null($command)) {
@@ -2676,7 +2678,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $fqdn,
'is_build_time' => false,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -2687,7 +2690,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $generatedValue,
'is_build_time' => false,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -2712,7 +2716,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
}
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
])->first();
if ($foundEnv) {
@@ -2722,7 +2727,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($foundEnv) {
$foundEnv->update([
'key' => $key,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_build_time' => $isBuildTime,
'value' => $defaultValue,
]);
@@ -2731,7 +2737,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $defaultValue,
'is_build_time' => $isBuildTime,
- 'application_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
diff --git a/database/migrations/2025_01_22_101105_remove_wrongly_created_envs.php b/database/migrations/2025_01_22_101105_remove_wrongly_created_envs.php
new file mode 100644
index 0000000000..cb1b3cbe6d
--- /dev/null
+++ b/database/migrations/2025_01_22_101105_remove_wrongly_created_envs.php
@@ -0,0 +1,19 @@
+<?php
+
+use App\Models\EnvironmentVariable;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\Log;
+
+return new class extends Migration
+{
+ public function up(): void
+ {
+ try {
+ EnvironmentVariable::whereNull('resourceable_id')->each(function (EnvironmentVariable $environmentVariable) {
+ $environmentVariable->delete();
+ });
+ } catch (\Exception $e) {
+ Log::error('Failed to delete wrongly created environment variables: '.$e->getMessage());
+ }
+ }
+};