File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ const argv = require('yargs')
98
98
description : 'Avoid creating alias `as` property in relations' ,
99
99
type : 'boolean'
100
100
} )
101
+ . option ( 'noIndexes' , {
102
+ description : 'Prevent writing index information in the models' ,
103
+ type : 'boolean'
104
+ } )
101
105
. option ( 'noInitModels' , {
102
106
description : 'Prevent writing the init-models file' ,
103
107
type : 'boolean'
@@ -215,6 +219,7 @@ async function readPassword() {
215
219
configFile . username = argv . user || configFile . username ;
216
220
configFile . useDefine = argv . useDefine || configFile . useDefine || false ;
217
221
configFile . indentation = argv . indentation || configFile . indentation || 2 ;
222
+ configFile . noIndexes = argv . noIndexes || configFile . noIndexes || false ;
218
223
219
224
console . log ( _ . omit ( configFile , 'password' ) ) ;
220
225
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export class AutoGenerator {
24
24
schema ?: string ;
25
25
singularize : boolean ;
26
26
useDefine : boolean ;
27
+ noIndexes ?: boolean ;
27
28
} ;
28
29
29
30
constructor ( tableData : TableData , dialect : DialectOptions , options : AutoOptions ) {
@@ -220,7 +221,9 @@ export class AutoGenerator {
220
221
}
221
222
222
223
// add indexes
223
- str += this . addIndexes ( table ) ;
224
+ if ( ! this . options . noIndexes ) {
225
+ str += this . addIndexes ( table ) ;
226
+ }
224
227
225
228
str = space [ 2 ] + str . trim ( ) ;
226
229
str = str . substring ( 0 , str . length - 1 ) ;
Original file line number Diff line number Diff line change @@ -153,6 +153,8 @@ export interface AutoOptions {
153
153
lang ?: LangOption ;
154
154
/** Whether to avoid creating alias property in relations */
155
155
noAlias ?: boolean ;
156
+ /** Whether to skip writing index information */
157
+ noIndexes ?: boolean ;
156
158
/** Whether to skip writing the init-models file */
157
159
noInitModels ?: boolean ;
158
160
/** Whether to skip writing the files */
You can’t perform that action at this time.
0 commit comments