Set range fileds to be integer instead of strings
This commit is contained in:
63
app/migrations/20190529133445-range-fields.js
Normal file
63
app/migrations/20190529133445-range-fields.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'size', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSize', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'price', { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'sizeRange', {
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'size', {
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSize', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'price', {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.sequelize.transaction((t) => {
|
||||||
|
return Promise.all([
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'sizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSizeRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'priceRange', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'size', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'gardenSize', { transaction: t }),
|
||||||
|
queryInterface.removeColumn('RealEstateRequests', 'price', { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'sizeRange', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSizeRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'priceRange', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'size', {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'gardenSize', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t }),
|
||||||
|
queryInterface.addColumn('RealEstateRequests', 'price', {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
}, { transaction: t })
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -12,12 +12,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
email: DataTypes.STRING,
|
email: DataTypes.STRING,
|
||||||
region: DataTypes.STRING,
|
region: DataTypes.STRING,
|
||||||
municipality: DataTypes.STRING,
|
municipality: DataTypes.STRING,
|
||||||
size: DataTypes.STRING,
|
size: DataTypes.INTEGER,
|
||||||
sizeRange: DataTypes.STRING,
|
sizeRange: DataTypes.INTEGER,
|
||||||
gardenSize: DataTypes.STRING,
|
gardenSize: DataTypes.INTEGER,
|
||||||
gardenSizeRange: DataTypes.STRING,
|
gardenSizeRange: DataTypes.INTEGER,
|
||||||
price: DataTypes.STRING,
|
price: DataTypes.INTEGER,
|
||||||
priceRange: DataTypes.STRING,
|
priceRange: DataTypes.INTEGER,
|
||||||
bounding_box: DataTypes.GEOMETRY('POINT', 4326)
|
bounding_box: DataTypes.GEOMETRY('POINT', 4326)
|
||||||
}, {});
|
}, {});
|
||||||
RealEstateRequest.associate = function(models) {
|
RealEstateRequest.associate = function(models) {
|
||||||
|
|||||||
Reference in New Issue
Block a user