fix: handle missing server_permissions table gracefully

- Wrap ServerPermission queries in try-catch so show/edit don't 500
  when the migration hasn't been run yet
- Same protection for save calls in store/update (both web and API)
This commit is contained in:
2026-06-13 10:55:14 -04:00
parent c4118c6e6a
commit e99615c162
2 changed files with 46 additions and 18 deletions

View File

@@ -178,8 +178,12 @@ class ApiController
$id = $serverModel->create($input);
if (!empty($permissions)) {
$permModel = new ServerPermission();
$permModel->save($id, $permissions);
try {
$permModel = new ServerPermission();
$permModel->save($id, $permissions);
} catch (\Throwable $e) {
// Table may not exist yet
}
}
$this->view->json([
@@ -238,8 +242,12 @@ class ApiController
$serverModel->update($id, $input);
if (!empty($permissions)) {
$permModel = new ServerPermission();
$permModel->save($id, $permissions);
try {
$permModel = new ServerPermission();
$permModel->save($id, $permissions);
} catch (\Throwable $e) {
// Table may not exist yet
}
}
$this->view->json([