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')
9898 description : 'Avoid creating alias `as` property in relations' ,
9999 type : 'boolean'
100100 } )
101+ . option ( 'noIndexes' , {
102+ description : 'Prevent writing index information in the models' ,
103+ type : 'boolean'
104+ } )
101105 . option ( 'noInitModels' , {
102106 description : 'Prevent writing the init-models file' ,
103107 type : 'boolean'
@@ -215,6 +219,7 @@ async function readPassword() {
215219 configFile . username = argv . user || configFile . username ;
216220 configFile . useDefine = argv . useDefine || configFile . useDefine || false ;
217221 configFile . indentation = argv . indentation || configFile . indentation || 2 ;
222+ configFile . noIndexes = argv . noIndexes || configFile . noIndexes || false ;
218223
219224 console . log ( _ . omit ( configFile , 'password' ) ) ;
220225
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export class AutoGenerator {
2424 schema ?: string ;
2525 singularize : boolean ;
2626 useDefine : boolean ;
27+ noIndexes ?: boolean ;
2728 } ;
2829
2930 constructor ( tableData : TableData , dialect : DialectOptions , options : AutoOptions ) {
@@ -220,7 +221,9 @@ export class AutoGenerator {
220221 }
221222
222223 // add indexes
223- str += this . addIndexes ( table ) ;
224+ if ( ! this . options . noIndexes ) {
225+ str += this . addIndexes ( table ) ;
226+ }
224227
225228 str = space [ 2 ] + str . trim ( ) ;
226229 str = str . substring ( 0 , str . length - 1 ) ;
Original file line number Diff line number Diff line change @@ -153,6 +153,8 @@ export interface AutoOptions {
153153 lang ?: LangOption ;
154154 /** Whether to avoid creating alias property in relations */
155155 noAlias ?: boolean ;
156+ /** Whether to skip writing index information */
157+ noIndexes ?: boolean ;
156158 /** Whether to skip writing the init-models file */
157159 noInitModels ?: boolean ;
158160 /** Whether to skip writing the files */
You can’t perform that action at this time.
0 commit comments