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

class ReputationActionLog extends Model {}

ReputationActionLog.init(
  {
    falukantUserId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      field: 'falukant_user_id',
    },
    actionTypeId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      field: 'action_type_id',
    },
    cost: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    baseGain: {
      type: DataTypes.INTEGER,
      allowNull: false,
      field: 'base_gain',
    },
    gain: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    timesUsedBefore: {
      type: DataTypes.INTEGER,
      allowNull: false,
      field: 'times_used_before',
    },
    actionTimestamp: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
      field: 'action_timestamp',
    },
  },
  {
    sequelize,
    modelName: 'ReputationActionLog',
    tableName: 'reputation_action',
    schema: 'falukant_log',
    timestamps: false,
    underscored: true,
    indexes: [
      { fields: ['falukant_user_id', 'action_type_id'] },
      { fields: ['action_timestamp'] },
    ],
  }
);

export default ReputationActionLog;


