Merge pull request #17162 from nrschultz/sequelize-query-interface-constraint-management

sequelize: add addConstraint and removeConstraint definitions
This commit is contained in:
Mine Starks
2017-06-15 17:13:02 -07:00
committed by GitHub
+45
View File
@@ -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<void>;
/**
* Adds constraints to a table
*/
addConstraint(tableName: string, attributes: string[], options?: AddConstraintOptions | QueryInterfaceOptions): Promise<void>;
/**
* Removes constraints from a table
*/
removeConstraint(tableName: string, constraintName: string, options?: QueryInterfaceOptions): Promise<void>;
/**
* Inserts a new record
*/