admin 发表于 2020-2-26 23:32:58

进销存系统数据隔离

隔离的方式每一张表都会有一个租户 id,每一次操作都会写入对应的租户 id,以保证数据的隔离识别性。-- ----------------------------
-- 时间:2019年3月18日
-- version:1.0.11
-- 此次更新
-- 1、批量增加大部分表的tenant_id租户字段
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
-- ----------------------------
alter table jsh_account add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_accounthead add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_accountitem add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_asset add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_assetcategory add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_assetname add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_depot add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_depothead add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_depotitem add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_inoutitem add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_log add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_material add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_materialcategory add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_orga_user_rel add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_organization add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_person add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_role add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_serial_number add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_supplier add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_systemconfig add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_unit add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_user add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
-- ----------------------------
-- 时间:2019年4月24日
-- version:1.0.14
-- 此次更新
-- 1、批量增加部分表的tenant_id租户字段
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
-- ----------------------------
alter table databasechangelog add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table databasechangeloglock add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_app add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_functions add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_materialproperty add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter table jsh_userbusiness add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
注册时初始化注册时需要给注册用户创建一个独立的空间(数据初始化)。需要初始化的数据

注册时验证登录名和用户名是否存在登录名保持全局唯一,不然两个公司的员工用相同的登录名无法识别。
用户名同一个租户范围内内唯一添加新用户需要对新用户进行数据范围界定添加用户数据范围界定添加新用户时,该用户可以使用的数据空间需要做一个界定,最大范围一定是创建该用户的租户所能达到的范围,但最小范围是什么呢?
添加新用户登录名和用户名校验登录名保持全局唯一,不然两个公司的员工用相同的登录名无法识别。
用户名同一个租户范围内内唯一sequence 表sequence 表中用于生成单据编号的 depot_number_seq 取值范围为 -9223372036854775808 - 9223372036854775807
在这样的大数量级下,可以不做隔离,但是用户多起来之后会达到 mysql 的写入性能瓶颈,在那种情况下就需要考虑用特殊的方式去维护。
页: [1]
查看完整版本: 进销存系统数据隔离