-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting up migrations int the application (#183)
- Loading branch information
Guillermo Gonzalez
committed
Apr 14, 2023
1 parent
1a912c6
commit 0d4090b
Showing
16 changed files
with
199 additions
and
22,951 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = ({ env }) => ({ | ||
// apiToken: { | ||
// salt: env('API_TOKEN_SALT', 'someRandomLongString'), | ||
// }, | ||
// auditLogs: { // only accessible with an Enterprise plan | ||
// enabled: env.bool('AUDIT_LOGS_ENABLED', true), | ||
// }, | ||
auth: { | ||
secret: env('ADMIN_JWT_SECRET', 'someSecretKey'), | ||
}, | ||
// transfer: { | ||
// token: { | ||
// salt: env('TRANSFER_TOKEN_SALT', 'anotherRandomLongString'), | ||
// } | ||
// }, | ||
autoOpen: false | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = ({ env }) => ({ | ||
// apiToken: { | ||
// salt: env('API_TOKEN_SALT', 'someRandomLongString'), | ||
// }, | ||
// auditLogs: { // only accessible with an Enterprise plan | ||
// enabled: env.bool('AUDIT_LOGS_ENABLED', true), | ||
// }, | ||
auth: { | ||
secret: 'test-admin', | ||
}, | ||
// transfer: { | ||
// token: { | ||
// salt: env('TRANSFER_TOKEN_SALT', 'anotherRandomLongString'), | ||
// } | ||
// }, | ||
autoOpen: false | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
'migrations': { | ||
enabled: true, | ||
config: { | ||
autoStart: true, | ||
migrationFolderPath : 'migrations' | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
async function createRoleIfNotExist(type, name, description) { | ||
let role = await strapi.query('role', 'users-permissions').findOne({type}); | ||
if (!role) { | ||
role = await strapi.query('role', 'users-permissions').create({name, description, type}); | ||
} | ||
return role; | ||
} | ||
|
||
async function updateRolePermissions(role, controller, action, enabled) { | ||
await strapi.query('permission', 'users-permissions') | ||
.update({role: role.id, controller, action}, {enabled}); | ||
} | ||
|
||
module.exports = async () => { | ||
let staffRole = await createRoleIfNotExist( | ||
'staff', 'Staff', 'Users that can review the all the articles'); | ||
// let adminRole = await createRoleIfNotExist( | ||
// 'administrator', 'Administrator', 'Administration control in the application'); | ||
|
||
const controllers = [{ | ||
name: 'episode', | ||
actions: ['count', 'find', 'findone'], | ||
enabled: true | ||
}]; | ||
|
||
for (let controller of controllers) { | ||
for (let action of controller.actions) { | ||
await updateRolePermissions(staffRole, controller.name, action, controller.enabled); | ||
} | ||
} | ||
}; |
Oops, something went wrong.