diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 952b3a7aea..8216424394 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -5,6 +5,7 @@ // Ivan Drinchev // Brendan Abolivier // Patsakol Tangjitcharoenchai +// Sebastien Bramille // Nick Mueller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -4176,7 +4177,7 @@ declare namespace sequelize { /** * Adds a new index to a table */ - addIndex(tableName: string | Object, attributes: string[], options?: QueryOptions, + addIndex(tableName: string | Object, attributes: string[], options?: DefineIndexOptions, rawTablename?: string): Promise; /** @@ -4826,6 +4827,38 @@ declare namespace sequelize { } + interface DefineIndexOptions { + /** + * The index type + */ + indicesType?: 'UNIQUE' | 'FULLTEXT' | 'SPATIAL'; + + /** + * The name of the index. Default is __ + */ + indexName?: string; + + /** + * For FULLTEXT columns set your parser + */ + parser?: string; + + /** + * Set a type for the index, e.g. BTREE. See the documentation of the used dialect + */ + indexType?: string; + + /** + * A function that receives the sql query, e.g. console.log + */ + logging?: Function; + + /** + * A hash of attributes to limit your index(Filtered Indexes - MSSQL & PostgreSQL only) + */ + where?: AnyWhereOptions; + } + /** * Interface for indexes property in DefineOptions * diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 4423ed9246..4ecbb8a1b0 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -1091,6 +1091,7 @@ queryInterface.createTable( 'table', { name : { type : Sequelize.STRING } }, { s queryInterface.addIndex( { schema : 'a', tableName : 'c' }, ['d', 'e'], { logging : function() {} }, 'schema_table' ); queryInterface.showIndex( { schema : 'schema', tableName : 'table' }, { logging : function() {} } ); queryInterface.addIndex( 'Group', ['from'] ); +queryInterface.addIndex( 'Group', ['from'], { indexName: 'group_from' } ); queryInterface.describeTable( '_Users', { logging : function() {} } ); queryInterface.createTable( 's', { table_id : { type : Sequelize.INTEGER, primaryKey : true, autoIncrement : true } } ); /* NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590