From cebef8e2583d69a50d6483c227ab04fe1a8652df Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 27 Feb 2026 11:54:22 +0100 Subject: [PATCH] fix(policies): ensure instance-level databases use root team Instance-level databases like coolify-db (with id = 0) should always be assigned to the root team (id = 0) rather than attempting to resolve their team from the database object itself. --- app/Policies/DatabasePolicy.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Policies/DatabasePolicy.php b/app/Policies/DatabasePolicy.php index 6a5348224..f62ffdde2 100644 --- a/app/Policies/DatabasePolicy.php +++ b/app/Policies/DatabasePolicy.php @@ -109,6 +109,11 @@ class DatabasePolicy private function getTeamId($database): ?int { + // Instance-level databases (e.g., coolify-db) belong to root team + if (isset($database->id) && $database->id === 0) { + return 0; + } + if (method_exists($database, 'team')) { return $database->team()?->id; }