const Sequelize = require("sequelize");

module.exports = (db) => {
  const biz_api_call_log = db.define(
    "biz_api_call_log",
    {
  
      user_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      token_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      api_path: {
        type: Sequelize.STRING(200),
        allowNull: false,
      },
      http_method: {
        type: Sequelize.STRING(10),
        allowNull: false,
        defaultValue: "POST",
      },
      status_code: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
      },
      response_time: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
      },
      call_date: {
        type: Sequelize.DATEONLY,
        allowNull: false,
      },
      created_at: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW,
      },
    },
    {
      tableName: "biz_api_call_log",
      freezeTableName: true,
      timestamps: false,
      underscored: true,
    }
  );
  return biz_api_call_log;
};
