92 lines
1.9 KiB
JavaScript
92 lines
1.9 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const sequelize = require('../config/db');
|
|
|
|
const SubscriptionPlan = sequelize.define('SubscriptionPlan', {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
comment: 'Plan ID'
|
|
},
|
|
code: {
|
|
type: DataTypes.STRING(50),
|
|
allowNull: false,
|
|
unique: true,
|
|
comment: 'Plan code'
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
comment: 'Plan name'
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'Plan description'
|
|
},
|
|
maxApartments: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 10,
|
|
comment: 'Apartment limit'
|
|
},
|
|
maxRooms: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 50,
|
|
comment: 'Room limit'
|
|
},
|
|
maxUsers: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 5,
|
|
comment: 'User limit'
|
|
},
|
|
monthlyPrice: {
|
|
type: DataTypes.DECIMAL(10, 2),
|
|
defaultValue: 0,
|
|
comment: 'Monthly price'
|
|
},
|
|
yearlyPrice: {
|
|
type: DataTypes.DECIMAL(10, 2),
|
|
defaultValue: 0,
|
|
comment: 'Yearly price'
|
|
},
|
|
isDefault: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: false,
|
|
comment: 'Whether this is the default plan'
|
|
},
|
|
status: {
|
|
type: DataTypes.ENUM('active', 'inactive'),
|
|
defaultValue: 'active',
|
|
comment: 'Plan status'
|
|
},
|
|
sort: {
|
|
type: DataTypes.INTEGER,
|
|
defaultValue: 0,
|
|
comment: 'Sort order'
|
|
},
|
|
isDeleted: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 0,
|
|
comment: 'Soft delete flag'
|
|
},
|
|
createTime: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW,
|
|
comment: 'Created time'
|
|
},
|
|
updateTime: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW,
|
|
comment: 'Updated time'
|
|
}
|
|
}, {
|
|
tableName: 'subscription_plans',
|
|
timestamps: false,
|
|
comment: 'Subscription plans'
|
|
});
|
|
|
|
module.exports = SubscriptionPlan;
|