import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';

class DaySell extends Model { }

DaySell.init({
    regionId: {
        type: DataTypes.INTEGER,
        allowNull: false},
    productId: {
        type: DataTypes.INTEGER,
        allowNull: false},
    quantity: {
        type: DataTypes.INTEGER,
        allowNull: false},
    sellerId: { 
        type: DataTypes.INTEGER,
        allowNull: false},
    sellTimestamp: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: sequelize.literal('CURRENT_TIMESTAMP')}
}, {
    sequelize,
    modelName: 'DaySell',
    tableName: 'sell',
    schema: 'falukant_log',
    timestamps: false,
    underscored: true,
    indexes: [
        {
            unique: true,
            fields: ['seller_id', 'product_id', 'region_id']
        }
    ]
});

export default DaySell;
