From b96ce17dbf9b73fc9b4843f124b8f68d89547596 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Tue, 17 Sep 2019 09:07:14 +0200 Subject: [PATCH] add unique constraint - composite key to the RealEstates table --- ...090318-add-composite-key-to-realEstates.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/migrations/20190917090318-add-composite-key-to-realEstates.js diff --git a/app/migrations/20190917090318-add-composite-key-to-realEstates.js b/app/migrations/20190917090318-add-composite-key-to-realEstates.js new file mode 100644 index 0000000..feb84b2 --- /dev/null +++ b/app/migrations/20190917090318-add-composite-key-to-realEstates.js @@ -0,0 +1,21 @@ +"use strict"; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.addConstraint( + "RealEstates", + ["originAgencyName", "agencyObjectId"], + { + type: "unique", + name: "agencyNameObjectIdUniqueKey" + } + ); + }, + + down: (queryInterface, Sequelize) => { + return queryInterface.removeConstraint( + "RealEstates", + "agencyNameObjectIdUniqueKey" + ); + } +};