const Sequelize = require("sequelize");

module.exports = (db) => {
  const biz_plan = db.define(
    "biz_plan",
    {
  
      plan_code: {
        type: Sequelize.STRING(64),
        allowNull: false,
        unique: true,
      },
      plan_name: {
        type: Sequelize.STRING(128),
        allowNull: false,
        defaultValue: "",
      },
      monthly_price: {
        type: Sequelize.DECIMAL(12, 2),
        allowNull: false,
        defaultValue: 0,
      },
      auth_fee: {
        type: Sequelize.DECIMAL(12, 2),
        allowNull: false,
        defaultValue: 0,
      },
      account_limit: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      active_user_limit: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      msg_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      mass_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      friend_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      sns_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
      enabled_features: {
        type: Sequelize.JSON,
        allowNull: true,
      },
      allowed_apis: {
        type: Sequelize.JSON,
        allowNull: true,
      },
      api_call_quota: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
      },
      status: {
        type: Sequelize.ENUM("active", "inactive"),
        allowNull: false,
        defaultValue: "active",
      },
    },
    {
      timestamps: false,
      underscored: true,
    }
  );
  // biz_plan.sync({ alter: true });
  return biz_plan;
};
