Skip to content

Commit

Permalink
misc: improve error logging in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik committed Aug 9, 2024
1 parent 4091a24 commit e300c10
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/extensions/migration-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export async function getUserPermissions (collectionName) {
}

export async function updatePermissions (readPermissions, fieldsToAdd, fieldsToRemove) {
if (!readPermissions) {
throw new Error(`Permissions object is empty.`);
}

if (!readPermissions.id) {
console.error(readPermissions);
throw new Error(`Permissions ID is missing. This may happen when there are multiple rows for the same permission type.`);
}

const URL = `${DIRECTUS_URL}/permissions/${readPermissions.id}?access_token=${ADMIN_ACCESS_TOKEN}`;
const filteredFields = readPermissions.fields.filter(field => !fieldsToRemove.includes(field));

Expand Down

0 comments on commit e300c10

Please sign in to comment.