const Sequelize = require("sequelize");

/** 租户表：用户、角色按 tenant_id 隔离；is_platform=1 的租户可管理本表 */
module.exports = (db) => {
  return db.define("sys_tenant", {
    name: {
      type: Sequelize.STRING(100),
      allowNull: false,
      defaultValue: "",
      comment: "租户名称",
    },
    code: {
      type: Sequelize.STRING(64),
      allowNull: false,
      defaultValue: "",
      unique: true,
      comment: "租户编码（登录时与账号一起使用）",
    },
    remark: {
      type: Sequelize.STRING(255),
      allowNull: false,
      defaultValue: "",
      comment: "备注",
    },
    /** 1 启用 0 停用 */
    status: {
      type: Sequelize.INTEGER(1),
      allowNull: false,
      defaultValue: 1,
      comment: "状态",
    },
    /** 1 平台租户：可维护租户表、可代建任意租户用户 */
    is_platform: {
      type: Sequelize.INTEGER(1),
      allowNull: false,
      defaultValue: 0,
      comment: "是否平台租户",
    },
  });
};
