mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-31 16:14:46 +02:00
Fix ensure issue
This commit is contained in:
parent
a875b65e5b
commit
8cd6cbb5ac
1 changed files with 6 additions and 0 deletions
|
@ -2,6 +2,7 @@ import { ActionsEnum } from "@server/auth/actions";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { actions, roles, roleActions } from "./schema";
|
import { actions, roles, roleActions } from "./schema";
|
||||||
import { eq, and, inArray, notInArray } from "drizzle-orm";
|
import { eq, and, inArray, notInArray } from "drizzle-orm";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
|
||||||
export async function ensureActions() {
|
export async function ensureActions() {
|
||||||
const actionIds = Object.values(ActionsEnum);
|
const actionIds = Object.values(ActionsEnum);
|
||||||
|
@ -17,6 +18,11 @@ export async function ensureActions() {
|
||||||
.where(eq(roles.isSuperuserRole, true))
|
.where(eq(roles.isSuperuserRole, true))
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
if (defaultRoles.length === 0) {
|
||||||
|
logger.info('No default roles to assign');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add new actions
|
// Add new actions
|
||||||
for (const actionId of actionsToAdd) {
|
for (const actionId of actionsToAdd) {
|
||||||
await db.insert(actions).values({ actionId }).execute();
|
await db.insert(actions).values({ actionId }).execute();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue