File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
core/server/data/migrations/versions/2.6 Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ const _ = require ( 'lodash' ) ;
2
+ const utils = require ( '../../../schema/fixtures/utils' ) ;
3
+ const permissions = require ( '../../../../services/permissions' ) ;
4
+ const logging = require ( '../../../../lib/common/logging' ) ;
5
+
6
+ const resources = [ 'webhook' ] ;
7
+ const _private = { } ;
8
+
9
+ _private . getRelations = function getRelations ( resource ) {
10
+ return utils . findPermissionRelationsForObject ( resource ) ;
11
+ } ;
12
+
13
+ _private . printResult = function printResult ( result , message ) {
14
+ if ( result . done === result . expected ) {
15
+ logging . info ( message ) ;
16
+ } else {
17
+ logging . warn ( `(${ result . done } /${ result . expected } ) ${ message } ` ) ;
18
+ }
19
+ } ;
20
+
21
+ module . exports . config = {
22
+ transaction : true
23
+ } ;
24
+
25
+ module . exports . up = ( options ) => {
26
+ const localOptions = _ . merge ( {
27
+ context : { internal : true }
28
+ } , options ) ;
29
+
30
+ return Promise . map ( resources , ( resource ) => {
31
+ const relationToAdd = _private . getRelations ( resource ) ;
32
+
33
+ return utils . addFixturesForRelation ( relationToAdd , localOptions )
34
+ . then ( result => _private . printResult ( result , `Adding permissions_roles fixtures for ${ resource } s` ) )
35
+ . then ( ( ) => permissions . init ( localOptions ) ) ;
36
+ } ) ;
37
+ } ;
You can’t perform that action at this time.
0 commit comments