const { DataTypes } = require('sequelize');
const Coin = require('./Coin');

module.exports = (sequelize) => {
    const Price1m = sequelize.define('Price1m', {
        id: {
            type: DataTypes.BIGINT,
            autoIncrement: true,
            primaryKey: true,
        },
        coin_id: {
            type: DataTypes.BIGINT,
            references:{
                model: 'coins',
                key: 'id'
            }
        },
        asset_id: {
            type: DataTypes.BIGINT,
             references:{
                model: 'assets',
                key: 'id'
            }
        },
        current: {
            type: DataTypes.DECIMAL(20, 10),
            allowNull: false,
        },
        open: {
            type: DataTypes.DECIMAL(20, 10),
            allowNull: false,
        },
        high: {
            type: DataTypes.DECIMAL(20, 10),
            allowNull: false,
        },
        low: {
            type: DataTypes.DECIMAL(20, 10),
            allowNull: false,
        },
        close: {
            type: DataTypes.DECIMAL(20, 10),
            allowNull: false,
        },
        volume: {
            type: DataTypes.DECIMAL(28, 10),
            defaultValue: 0,
        },
        timestamp: {
            type: DataTypes.DATE,
            allowNull: false,
        }
    }, {
        tableName: 'price_1m',
        timestamps: false,
        indexes: [
            {
                fields: ['coin_id','asset_id', 'timestamp'],
            },
        ],
    });
    return Price1m

}