瀏覽代碼

Fix ensure issue

Owen Schwartz 9 月之前
父節點
當前提交
8cd6cbb5ac
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      server/db/ensureActions.ts

+ 6 - 0
server/db/ensureActions.ts

@@ -2,6 +2,7 @@ import { ActionsEnum } from "@server/auth/actions";
 import { db } from "@server/db";
 import { actions, roles, roleActions } from "./schema";
 import { eq, and, inArray, notInArray } from "drizzle-orm";
+import logger from "@server/logger";
 
 export async function ensureActions() {
     const actionIds = Object.values(ActionsEnum);
@@ -17,6 +18,11 @@ export async function ensureActions() {
         .where(eq(roles.isSuperuserRole, true))
         .execute();
 
+    if (defaultRoles.length === 0) {
+        logger.info('No default roles to assign');
+        return;
+    }
+
     // Add new actions
     for (const actionId of actionsToAdd) {
     await db.insert(actions).values({ actionId }).execute();