add createdAt, updatedAt fields; add default values for not null fields

This commit is contained in:
Bilal Catic
2019-09-13 10:56:46 +02:00
parent 81ecb37493
commit e32e98537c
3 changed files with 51 additions and 16 deletions

View File

@@ -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", {});
}
};