From b17b6862ba363af0c64193fb0667bf3e5a0d7a0e Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Tue, 18 Jun 2019 13:13:16 +0200 Subject: [PATCH] Added migrations, expanded maketalert table --- .../20190618103020-expand-maketalert.js | 37 +++++++++++++++++++ ...0618124522-marketalerts-additional-info.js | 33 +++++++++++++++++ app/models/marketalert.js | 4 +- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/migrations/20190618103020-expand-maketalert.js create mode 100644 app/migrations/20190618124522-marketalerts-additional-info.js diff --git a/app/migrations/20190618103020-expand-maketalert.js b/app/migrations/20190618103020-expand-maketalert.js new file mode 100644 index 0000000..54eed96 --- /dev/null +++ b/app/migrations/20190618103020-expand-maketalert.js @@ -0,0 +1,37 @@ +'use strict'; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction((t) => { + return Promise.all([ + queryInterface.addColumn('MarketAlerts', 'size', { + type: Sequelize.INTEGER, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'gardenSize', { + type: Sequelize.INTEGER, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'price', { + type: Sequelize.INTEGER, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'municipality', { + type: Sequelize.STRING, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'region', { + type: Sequelize.STRING, + }, { transaction: t }) + ]) + }) + }, + + down: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction((t) => { + return Promise.all([ + queryInterface.removeColumn('MarketAlerts', 'size', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'gardenSize', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'price', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'municipality', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'region', { transaction: t }) + ]) + }) + } +}; diff --git a/app/migrations/20190618124522-marketalerts-additional-info.js b/app/migrations/20190618124522-marketalerts-additional-info.js new file mode 100644 index 0000000..48847d1 --- /dev/null +++ b/app/migrations/20190618124522-marketalerts-additional-info.js @@ -0,0 +1,33 @@ +'use strict'; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction((t) => { + return Promise.all([ + queryInterface.removeColumn('MarketAlerts', 'olxUrl', { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'url', { + type: Sequelize.STRING, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'realestateOrigin', { + type: Sequelize.STRING, + }, { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'originId', { + type: Sequelize.STRING, + }, { transaction: t }) + ]) + }) + }, + + down: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction((t) => { + return Promise.all([ + queryInterface.removeColumn('MarketAlerts', 'url', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'realestateOrigin', { transaction: t }), + queryInterface.removeColumn('MarketAlerts', 'originId', { transaction: t }), + queryInterface.addColumn('MarketAlerts', 'olxUrl', { + type: Sequelize.STRING + }, { transaction: t }) + ]) + }) + } +}; diff --git a/app/models/marketalert.js b/app/models/marketalert.js index ac08ac4..c0665a3 100644 --- a/app/models/marketalert.js +++ b/app/models/marketalert.js @@ -1,7 +1,9 @@ 'use strict'; module.exports = (sequelize, DataTypes) => { const MarketAlert = sequelize.define('MarketAlert', { - olxUrl: DataTypes.STRING, + url: DataTypes.STRING, + realestateOrigin: DataTypes.STRING, + originId: DataTypes.STRING, lastDate: DataTypes.STRING, email: { type: DataTypes.STRING,