Updated gerbil key handeling

This commit is contained in:
Owen Schwartz
2024-10-26 17:02:11 -04:00
parent 6cee5703b5
commit 7feb21e727
5 changed files with 25 additions and 17 deletions

View File

@@ -20,9 +20,10 @@ export async function ensureActions() {
// Add new actions
for (const actionId of actionsToAdd) {
logger.debug(`Adding action: ${actionId}`);
await db.insert(actions).values({ actionId }).execute();
// Add new actions to the Default role
if (defaultRoles.length === 0) {
if (defaultRoles.length != 0) {
await db.insert(roleActions)
.values(defaultRoles.map(role => ({ roleId: role.roleId!, actionId, orgId: role.orgId! })))
.execute();
@@ -31,6 +32,7 @@ export async function ensureActions() {
// Remove deprecated actions
if (actionsToRemove.length > 0) {
logger.debug(`Removing actions: ${actionsToRemove.join(', ')}`);
await db.delete(actions).where(inArray(actions.actionId, actionsToRemove)).execute();
await db.delete(roleActions).where(inArray(roleActions.actionId, actionsToRemove)).execute();
}