rentease-backend-new/models/SubscriptionPlan.js

92 lines
1.9 KiB
JavaScript
Raw Normal View History

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