const Sequelize = require("sequelize");

module.exports = (db) => {
  const biz_subscription = db.define(
    "biz_subscription",
    {
  
      user_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      plan_id: {
        type: Sequelize.BIGINT.UNSIGNED,
        allowNull: false,
      },
      status: {
        type: Sequelize.ENUM("pending", "active", "expired", "cancelled"),
        allowNull: false,
        defaultValue: "pending",
      },
      start_time: { type: Sequelize.DATE, allowNull: false },
      end_time: { type: Sequelize.DATE, allowNull: false },
      renew_mode: {
        type: Sequelize.ENUM("manual", "auto"),
        allowNull: false,
        defaultValue: "manual",
      },
      payment_channel: {
        type: Sequelize.ENUM("offline", "pay_link"),
        allowNull: true,
      },
      payment_ref: {
        type: Sequelize.STRING(200),
        allowNull: true,
      },
    },
    {
      tableName: "biz_subscriptions",
      timestamps: false,
      underscored: true,
    }
  );
  // biz_subscription.sync({ alter: true });
  return biz_subscription;
};
