Skip to content

Commit 60d9307

Browse files
committed
Add --noIndexes option (#563)
1 parent 031b281 commit 60d9307

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

bin/sequelize-auto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/auto-generator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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);

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 */

0 commit comments

Comments
 (0)