@@ -52,7 +52,16 @@ module.exports = function (S) {
52
52
option : 'stage' ,
53
53
shortcut : 's' ,
54
54
description : 'Stage that dynamodb should be remotely executed'
55
- } ]
55
+ } , {
56
+ option : 'table_prefix' ,
57
+ shortcut : 'p' ,
58
+ description : 'Table name prefix'
59
+ } , {
60
+ option : 'table_suffix' ,
61
+ shortcut : 'x' ,
62
+ description : 'Table name suffix'
63
+ }
64
+ ]
56
65
} ) ;
57
66
S . addAction ( this . executeAll . bind ( this ) , {
58
67
handler : 'dynamodbExecuteAll' ,
@@ -67,6 +76,14 @@ module.exports = function (S) {
67
76
option : 'stage' ,
68
77
shortcut : 's' ,
69
78
description : 'Stage that dynamodb should be remotely executed'
79
+ } , {
80
+ option : 'table_prefix' ,
81
+ shortcut : 'p' ,
82
+ description : 'Table name prefix'
83
+ } , {
84
+ option : 'table_suffix' ,
85
+ shortcut : 'x' ,
86
+ description : 'Table name suffix'
70
87
} ]
71
88
} ) ;
72
89
S . addAction ( this . remove . bind ( this ) , {
@@ -149,13 +166,13 @@ module.exports = function (S) {
149
166
} ;
150
167
}
151
168
152
- tableOptions ( ) {
169
+ tableOptions ( table_prefix , table_suffix ) {
153
170
let config = S . getProject ( ) . custom . dynamodb ,
154
171
migration = config && config . migration || { } ,
155
172
rootPath = S . getProject ( ) . getRootPath ( ) ,
156
173
path = rootPath + '/' + ( migration . dir || 'dynamodb' ) ,
157
- suffix = migration . table_suffix || '' ,
158
- prefix = migration . table_prefix || '' ;
174
+ suffix = table_suffix || migration . table_suffix || '' ,
175
+ prefix = table_prefix || migration . table_prefix || '' ;
159
176
160
177
return {
161
178
suffix : suffix ,
@@ -189,7 +206,7 @@ module.exports = function (S) {
189
206
options = evt . options ;
190
207
return new BbPromise ( function ( resolve , reject ) {
191
208
let dynamodb = self . dynamodbOptions ( options . stage , options . region ) ,
192
- tableOptions = self . tableOptions ( ) ;
209
+ tableOptions = self . tableOptions ( options . table_prefix , options . table_suffix ) ;
193
210
dynamodbMigrations . init ( dynamodb , tableOptions . path ) ;
194
211
dynamodbMigrations . execute ( options . name , tableOptions ) . then ( resolve , reject ) ;
195
212
} ) ;
@@ -200,7 +217,7 @@ module.exports = function (S) {
200
217
options = evt . options ;
201
218
return new BbPromise ( function ( resolve , reject ) {
202
219
let dynamodb = self . dynamodbOptions ( options . stage , options . region ) ,
203
- tableOptions = self . tableOptions ( ) ;
220
+ tableOptions = self . tableOptions ( options . table_prefix , options . table_suffix ) ;
204
221
dynamodbMigrations . init ( dynamodb , tableOptions . path ) ;
205
222
dynamodbMigrations . executeAll ( tableOptions ) . then ( resolve , reject ) ;
206
223
} ) ;
0 commit comments