diff --git a/app/migrations/20190912191829-add-realEstates-table.js b/app/migrations/20190912191829-add-realEstates-table.js index a64fa1e..e6b45b3 100644 --- a/app/migrations/20190912191829-add-realEstates-table.js +++ b/app/migrations/20190912191829-add-realEstates-table.js @@ -53,12 +53,20 @@ module.exports = { sold: { type: Sequelize.BOOLEAN, allowNull: false + }, + createdAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") + }, + updatedAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") } }; - return queryInterface.createTable("realEstates", tableFields); + return queryInterface.createTable("RealEstates", tableFields); }, down: queryInterface => { - return queryInterface.dropTable("realEstates", {}); + return queryInterface.dropTable("RealEstates", {}); } }; diff --git a/app/migrations/20190912215313-add-searchRequests-table.js b/app/migrations/20190912215313-add-searchRequests-table.js index a0cf331..ea2576d 100644 --- a/app/migrations/20190912215313-add-searchRequests-table.js +++ b/app/migrations/20190912215313-add-searchRequests-table.js @@ -10,8 +10,13 @@ module.exports = { primaryKey: true }, areaToSearch: { - type: Sequelize.GEOMETRY("POINT", 4326), - allowNull: false + type: Sequelize.GEOMETRY("POLYGON", 4326), + allowNull: false, + defaultValue: { + type: "Polygon", + coordinates: [[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], + crs: { type: "name", properties: { name: "EPSG:4326" } } + } }, realEstateType: { type: Sequelize.TEXT, @@ -19,7 +24,8 @@ module.exports = { }, adType: { type: Sequelize.TEXT, - allowNull: false + allowNull: false, + defaultValue: "sell" }, email: Sequelize.TEXT, locality: Sequelize.TEXT, @@ -30,31 +36,44 @@ module.exports = { country: Sequelize.TEXT, sizeMin: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, + defaultValue: 0 }, sizeMax: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, + defaultValue: 0 }, priceMin: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, + defaultValue: 0 }, priceMax: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, + defaultValue: 0 }, gardenSizeMin: Sequelize.INTEGER, gardenSizeMax: Sequelize.INTEGER, subscribed: { type: Sequelize.BOOLEAN, - allowNull: false + allowNull: false, + defaultValue: true + }, + createdAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") + }, + updatedAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") } }; - return queryInterface.createTable("searchRequests", tableFields); + return queryInterface.createTable("SearchRequests", tableFields); }, down: queryInterface => { - return queryInterface.dropTable("searchRequests", {}); + return queryInterface.dropTable("SearchRequests", {}); } }; diff --git a/app/migrations/20190912215556-add-searchRequestMatches-table.js b/app/migrations/20190912215556-add-searchRequestMatches-table.js index 24d80db..c3e05ce 100644 --- a/app/migrations/20190912215556-add-searchRequestMatches-table.js +++ b/app/migrations/20190912215556-add-searchRequestMatches-table.js @@ -13,7 +13,7 @@ module.exports = { allowNull: false, primaryKey: true, references: { - model: "searchRequests", + model: "SearchRequests", key: "id" }, onUpdate: "CASCADE", @@ -24,7 +24,7 @@ module.exports = { allowNull: false, primaryKey: true, references: { - model: "realEstates", + model: "RealEstates", key: "id" }, onUpdate: "CASCADE", @@ -34,12 +34,20 @@ module.exports = { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: false + }, + createdAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") + }, + updatedAt: { + type: Sequelize.DATE, + defaultValue: Sequelize.literal("NOW()") } }; - return queryInterface.createTable("searchRequestMatches", tableFields); + return queryInterface.createTable("SearchRequestMatches", tableFields); }, down: queryInterface => { - return queryInterface.dropTable("searchRequestMatches", {}); + return queryInterface.dropTable("SearchRequestMatches", {}); } };