[Sequelize] update queryInterface addIndex (#35284)

* fix sequelize addIndex

* add deprecated sequelize index options

* create sequelize IndexType
This commit is contained in:
Emmanuel Gautier
2019-05-13 16:10:03 -07:00
committed by Nathan Shively-Sanders
parent a0efee5960
commit dccf648e59
2 changed files with 37 additions and 4 deletions
+31 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Sequelize 4.27.11
// Type definitions for Sequelize 4.28.0
// Project: http://sequelizejs.com, https://github.com/sequelize/sequelize
// Definitions by: samuelneff <https://github.com/samuelneff>
// Peter Harris <https://github.com/codeanimal>
@@ -17,6 +17,7 @@
// Antoine Boisadam <https://github.com/Antoine38660>
// Dima Smirnov <https://github.com/smff>
// Duy Truong <https://github.com/truongkhanhduy95>
// Emmanuel Gautier <https://github.com/emmanuelgautier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -4337,6 +4338,7 @@ declare namespace sequelize {
/**
* Adds a new index to a table
*/
addIndex(tableName: string | Object, options: DefineIndexOptions & { fields: string[] }, rawTablename?: string): Promise<void>;
addIndex(tableName: string | Object, attributes: string[], options?: DefineIndexOptions,
rawTablename?: string): Promise<void>;
@@ -5001,17 +5003,34 @@ declare namespace sequelize {
}
type IndexType = 'UNIQUE' | 'FULLTEXT' | 'SPATIAL';
interface DefineIndexOptions {
/**
* The index type
*/
indicesType?: 'UNIQUE' | 'FULLTEXT' | 'SPATIAL';
indicesType?: IndexType;
/**
* The index type
*/
type?: IndexType;
/**
* The name of the index. Default is __
*/
indexName?: string;
/**
* Create a unique index
*/
unique?: boolean;
/**
* The name of the index. Default is Default is <table>_<attr1>_<attr2>
*/
name?: string;
/**
* For FULLTEXT columns set your parser
*/
@@ -5027,6 +5046,16 @@ declare namespace sequelize {
*/
logging?: Function;
/**
* Create an unique index
*/
using?: string;
/**
* Index operator
*/
operator?: string;
/**
* A hash of attributes to limit your index(Filtered Indexes - MSSQL & PostgreSQL only)
*/
+6 -2
View File
@@ -1195,8 +1195,12 @@ 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.addIndex("Group", ["from"], { concurrently: true });
queryInterface.addIndex( 'Group', ['from'], { indexName: 'group_from' });
queryInterface.addIndex( 'Group', ['from'], { type: 'FULLTEXT' });
queryInterface.addIndex( 'Group', ['from'], { indicesType: 'FULLTEXT' } );
queryInterface.addIndex( 'Group', ['from'], { concurrently: true } );
queryInterface.addIndex( 'Group', ['data'], { using: 'gin', operator: 'jsonb_path_ops' } );
queryInterface.addIndex( 'Group', { fields: ['data'], using: 'gin', operator: 'jsonb_path_ops' } );
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