Files
starr-philproperties/models/tiers/tier_plans.mdl.js
T
2026-08-05 04:32:43 +08:00

34 lines
2.3 KiB
JavaScript

/***********************************************************************************************************************************************************************
* File Name: tier_plans.mdl.js
* Type of Program: Model
* Description: Sequelize model for the `tier_plans` table.
* Catalog of fixed plans (premium/exclusive) with duration and price.
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Jun. 6, 2026
***********************************************************************************************************************************************************************/
const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_TierPlans = sequelize.define('TierPlan', {
plan_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, label: 'Plan ID' },
tier_category_id: { type: DataTypes.BIGINT, allowNull: true, label: 'Tier Category' },
tier: { type: DataTypes.STRING(50), allowNull: false, label: 'Tier' },
label: { type: DataTypes.STRING(100), allowNull: false, label: 'Plan Label' },
description: { type: DataTypes.TEXT, allowNull: true, label: 'Description' },
features: { type: DataTypes.JSONB, allowNull: true, label: 'Features', comment: 'Array of {text} — admin-authored "what\'s included" bullets shown on the client Plans page.' },
duration_days: { type: DataTypes.FLOAT, allowNull: false, label: 'Duration (Days)' },
duration_unit: { type: DataTypes.STRING(10), allowNull: false, defaultValue: 'day', label: 'Duration Unit' },
price: { type: DataTypes.DECIMAL(10, 2), allowNull: false, label: 'Price' },
currency: { type: DataTypes.CHAR(3), allowNull: false, defaultValue: 'USD', label: 'Currency' },
is_active: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true, label: 'Active' },
status: { type: DataTypes.ENUM('draft', 'published'), allowNull: false, defaultValue: 'draft', label: 'Status', hidden: false, filterable: true },
createdBy: { type: DataTypes.BIGINT, allowNull: true },
updatedBy: { type: DataTypes.BIGINT, allowNull: true },
deletedBy: { type: DataTypes.BIGINT, allowNull: true },
}, {
tableName: 'tier_plans',
timestamps: true,
paranoid: true,
});
module.exports = mdl_TierPlans;