MCPcopy Index your code
hub / github.com/sequelize/sequelize / addConstraint

Method addConstraint

src/dialects/abstract/query-interface.js:756–769  ·  view source on GitHub ↗

* Add a constraint to a table * * Available constraints: * - UNIQUE * - DEFAULT (MSSQL only) * - CHECK (MySQL - Ignored by the database engine ) * - FOREIGN KEY * - PRIMARY KEY * * @example UNIQUE * queryInterface.addConstraint('Users', { * field

(tableName, options)

Source from the content-addressed store, hash-verified

754 * @returns {Promise}
755 */
756 async addConstraint(tableName, options) {
757 if (!options.fields) {
758 throw new Error('Fields must be specified through options.fields');
759 }
760
761 if (!options.type) {
762 throw new Error('Constraint type must be specified through options.type');
763 }
764
765 options = Utils.cloneDeep(options);
766
767 const sql = this.queryGenerator.addConstraintQuery(tableName, options);
768 return await this.sequelize.query(sql, options);
769 }
770
771 async showConstraint(tableName, constraintName, options) {
772 const sql = this.queryGenerator.showConstraintsQuery(tableName, constraintName);

Callers 4

upsert.test.jsFile · 0.45
deferrable.test.jsFile · 0.45
testFunction · 0.45

Calls 2

addConstraintQueryMethod · 0.45
queryMethod · 0.45

Tested by 1

testFunction · 0.36