From 81a8b26f06f37c7b1929db08716a961f775aa246 Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 13 Jun 2017 14:11:41 -0400 Subject: [PATCH 1/3] add addConstraint and removeConstraint definitions --- types/sequelize/index.d.ts | 53 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 70c637e25a..fc09847e5e 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3982,6 +3982,41 @@ declare namespace sequelize { } + interface AddUniqueConstraintOptions { + type: 'unique'; + name?: string; + } + + interface AddDefaultConstraintOptions { + type: 'default'; + name?: string; + defaultValue?: any; + } + + interface AddCheckConstraintOptions { + type: 'check'; + name?: string; + where?: WhereOptions; + } + + interface AddPrimaryKeyConstraintOptions { + type: 'primary key'; + name?: string; + } + + interface AddForeignKeyConstraintOptions { + type: 'foreign key'; + name?: string; + references?: { + table: string; + field: string; + }; + onDelete: string; + onUpdate: string; + } + + type AddConstraintOptions = AddUniqueConstraintOptions | AddDefaultConstraintOptions | AddCheckConstraintOptions | AddPrimaryKeyConstraintOptions | AddForeignKeyConstraintOptions; + /** * The interface that Sequelize uses to talk to all databases. * @@ -4133,6 +4168,16 @@ declare namespace sequelize { removeIndex(tableName: string, indexNameOrAttributes: string[] | string, options?: QueryInterfaceOptions): Promise; + /** + * Adds constraints to a table + */ + addConstraint(tableName: string, attributes: string[], options: AddConstraintOptions | QueryInterfaceOptions): Promise; + + /** + * Removes constraints from a table + */ + removeConstraint(tableName: string, constraintName: string, options: QueryInterfaceOptions): Promise; + /** * Inserts a new record */ @@ -4517,10 +4562,10 @@ declare namespace sequelize { bind?: Object | string[]; /** - * Force the query to use the write pool, regardless of the query type. - * - * Defaults to false - */ + * Force the query to use the write pool, regardless of the query type. + * + * Defaults to false + */ useMaster?: boolean; /** From 031e22146e7082e43bcefaa542220bf685c3f42c Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 13 Jun 2017 14:22:40 -0400 Subject: [PATCH 2/3] make options optional --- types/sequelize/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index fc09847e5e..187321f90f 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -4171,12 +4171,12 @@ declare namespace sequelize { /** * Adds constraints to a table */ - addConstraint(tableName: string, attributes: string[], options: AddConstraintOptions | QueryInterfaceOptions): Promise; + addConstraint(tableName: string, attributes: string[], options?: AddConstraintOptions | QueryInterfaceOptions): Promise; /** * Removes constraints from a table */ - removeConstraint(tableName: string, constraintName: string, options: QueryInterfaceOptions): Promise; + removeConstraint(tableName: string, constraintName: string, options?: QueryInterfaceOptions): Promise; /** * Inserts a new record From c0abcfd8631d7154702c0e78265cb9d35fbd2e0a Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 13 Jun 2017 14:24:04 -0400 Subject: [PATCH 3/3] undo spacing change --- types/sequelize/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 187321f90f..47e6039f89 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -4562,10 +4562,10 @@ declare namespace sequelize { bind?: Object | string[]; /** - * Force the query to use the write pool, regardless of the query type. - * - * Defaults to false - */ + * Force the query to use the write pool, regardless of the query type. + * + * Defaults to false + */ useMaster?: boolean; /**