chore: remove raw sql from env relationship
- raw sql should not be used whenever possible - using sql to order on the relationship environment_variables() causes custom sorting to break or be additionally complicated
This commit is contained in:
parent
e9ef331def
commit
3af456cd35
10 changed files with 10 additions and 90 deletions
|
|
@ -845,15 +845,7 @@ public function detectPortFromEnvironment(?bool $isPreview = false): ?int
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
||||||
->where('is_preview', false)
|
->where('is_preview', false);
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN is_required = true THEN 1
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runtime_environment_variables()
|
public function runtime_environment_variables()
|
||||||
|
|
|
||||||
|
|
@ -1458,15 +1458,7 @@ public function scheduled_tasks(): HasMany
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN is_required = true THEN 1
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function workdir()
|
public function workdir()
|
||||||
|
|
|
||||||
|
|
@ -295,15 +295,7 @@ public function destination()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runtime_environment_variables()
|
public function runtime_environment_variables()
|
||||||
|
|
|
||||||
|
|
@ -324,14 +324,6 @@ public function isBackupSolutionAvailable()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,14 +324,6 @@ public function isBackupSolutionAvailable()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -289,15 +289,7 @@ public function destination(): MorphTo
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runtime_environment_variables()
|
public function runtime_environment_variables()
|
||||||
|
|
|
||||||
|
|
@ -349,14 +349,6 @@ public function isBackupSolutionAvailable()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -328,14 +328,6 @@ public function isBackupSolutionAvailable()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,15 +323,7 @@ public function scheduledBackups()
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBackupSolutionAvailable()
|
public function isBackupSolutionAvailable()
|
||||||
|
|
|
||||||
|
|
@ -374,14 +374,6 @@ public function redisUsername(): Attribute
|
||||||
|
|
||||||
public function environment_variables()
|
public function environment_variables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(EnvironmentVariable::class, 'resourceable')
|
return $this->morphMany(EnvironmentVariable::class, 'resourceable');
|
||||||
->orderByRaw("
|
|
||||||
CASE
|
|
||||||
WHEN LOWER(key) LIKE 'service_%' THEN 1
|
|
||||||
WHEN is_required = true AND (value IS NULL OR value = '') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
LOWER(key) ASC
|
|
||||||
");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue