Files

31 lines
1.8 KiB
JavaScript

/***********************************************************************************************************************************************************************
* File Name: user_tier_grants.mdl.js
* Type of Program: Model
* Description: Purchase-time snapshot of the exact courses/units/lessons a
* Tier Plan purchase granted. Replaces live re-resolution off
* plan_courses/plan_units/plan_lessons at access-check time, so
* editing a plan's bundle later no longer retroactively changes
* what past purchasers can access. See hasItemGrant() in
* controllers/client/courses.controller.js.
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Aug. 4, 2026
***********************************************************************************************************************************************************************/
const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_UserTierGrants = sequelize.define('UserTierGrant', {
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
user_tier_id: { type: DataTypes.BIGINT, allowNull: false, label: 'User Tier ID' },
user_id: { type: DataTypes.BIGINT, allowNull: false, label: 'User ID' },
plan_id: { type: DataTypes.BIGINT, allowNull: true, label: 'Plan ID' },
item_type: { type: DataTypes.STRING(10), allowNull: false, label: 'Item Type' },
item_id: { type: DataTypes.BIGINT, allowNull: false, label: 'Item ID' },
granted_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, label: 'Granted At' },
}, {
tableName: 'user_tier_grants',
timestamps: true,
paranoid: false,
});
module.exports = mdl_UserTierGrants;