Skip to content

移除/关闭多租户

最后更新: 几秒前
实践版本: v4.0.0

从 1.x 开始就持续有人在催更的多租户版本,已于 v4.0.0 正式上线。由于精力有限,原考虑的多租户分支和无租户分支并行的方式被放弃,从 v4.0.0 版本开始,ContiNew Admin 将开箱即带多租户能力。

有人欢喜有人忧,尤其部分持续跟进更新的老用户,非常担心多租户的集成会导致项目无法再跟进升级,为此,单独写一篇文档,说明如何移除/关闭多租户能力。

关闭租户配置

1.在 application.yml 中,将 continew-starter.tenant.enabled 设置为 false

yaml
--- ### 租户配置
continew-starter.tenant:
  enabled: false

2.从 db.changelog 下的 db.changelog-master.yaml 中注释掉相关的 plugin_tenant 脚本。

是的,你没看错,就是这样简单的配置,就可以关闭多租户能力。

移除租户相关代码

移除租户依赖

continew-common/pom.xml 中将 continew-starter-extension-tenant 依赖移除。

xml
<!-- ContiNew Starter 扩展模块 - 租户 -->
<dependency>
    <groupId>top.continew.starter</groupId>
    <artifactId>continew-starter-extension-tenant-mp</artifactId>
</dependency>

移除租户配置

application.yml 中移除租户相关配置。

yaml
--- ### 租户配置
continew-starter.tenant:
  xxx

移除 db.changelog 下的 plugin_tenant.sql 脚本, db.changelog-master.yaml 中也需要移除相关的 plugin_tenant 脚本配置。

移除租户模块

  1. continew-plugin 中移除 continew-plugin-tenant 模块。
  2. continew-server 中移除 continew-server-tenant 依赖。
  3. continew-common/api 包中移除 tenant 相关 API。
  4. 编译项目,检查其他报错位置并进行移除即可。

我们已经尽可能的将租户相关代码聚合在了 continew-plugin-tenant 模块中,而且已知功能也都通过 TenantContextHolder.isTenantEnabled() 进行了判断(如果有遗漏,欢迎反馈 PR),所以如果你只是想关闭多租户能力,我个人建议禁用租户配置即可。