const Sequelize = require("sequelize"); /** * 业务 API Token(管理端页面:admin/src/views/subscription/tokens.vue) * 动态路由 component 与 admin/src/router/component-map.js 中 * subscription/token 或 subscription/biz_api_token 对应。 */ module.exports = (db) => { const biz_api_token = db.define( "biz_api_token", { user_id: { type: Sequelize.BIGINT.UNSIGNED, allowNull: false, }, plan_id: { type: Sequelize.BIGINT.UNSIGNED, allowNull: true, }, token_name: { type: Sequelize.STRING(100), allowNull: false, defaultValue: "", }, key: { type: Sequelize.STRING(128), allowNull: true, }, token_hash: { type: Sequelize.STRING(64), allowNull: false, unique: true, }, secret_cipher: { type: Sequelize.TEXT, allowNull: true, }, status: { type: Sequelize.ENUM("active", "revoked", "expired"), allowNull: false, defaultValue: "active", }, expire_at: { type: Sequelize.DATE, allowNull: false }, last_used_at: { type: Sequelize.DATE, allowNull: true }, }, { tableName: "biz_api_token", freezeTableName: true, timestamps: false, underscored: true, } ); //biz_api_token.sync({ force: true }); return biz_api_token; };