const Sequelize = require("sequelize");

module.exports = (db) => {
  return db.define(
    "biz_usage_monthly",
    {
      id: {
        type: Sequelize.BIGINT.UNSIGNED,
        primaryKey: true,
        autoIncrement: true,
      },
      user_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      plan_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      stat_month: {
        type: Sequelize.STRING(7),
        allowNull: false,
        comment: "YYYY-MM",
      },
      msg_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      mass_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      friend_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      sns_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      active_user_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
    },
    {
      tableName: "biz_usage_monthly",
      timestamps: true,
      underscored: true,
      comment: "月用量",
    }
  );
};
