Files
old-web/app/models/priceHistory.js

36 lines
713 B
JavaScript

"use strict";
module.exports = (sequalize, DataTypes) => {
const PriceHistory = sequalize.define("PriceHistory", {
id: {
type: DataTypes.BIGINT,
autoIncrement: true,
primaryKey: true,
allowNull: false
},
realEstateId: {
type: DataTypes.BIGINT,
allowNull: false,
references: {
model: "RealEstate",
key: "id"
},
onUpdate: "CASCADE",
onDelete: "SET NULL"
},
price: DataTypes.REAL
});
PriceHistory.associate = models => {
PriceHistory.hasMany(models.RealEstate, {
foreignKey: "id",
sourceKey: "realEstateId",
targetKey: "id",
as: "realEstates"
});
};
return PriceHistory;
};