elder-yudao-pro/mysql_script/health/V006__health_social_support.sql

24 lines
1.7 KiB
MySQL
Raw Permalink Normal View History

-- 社会属性联动:海拔来源与双向配偶关系。无海拔数据不填零,不导入未知来源的数据。
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS health_region_altitude (
id bigint NOT NULL AUTO_INCREMENT,
area_code varchar(6) NOT NULL COMMENT '行政区划编码',
altitude decimal(10,2) NOT NULL COMMENT '经核实的平均海拔,米',
source varchar(500) NOT NULL COMMENT '数据来源和版本',
creator varchar(64) DEFAULT '', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater varchar(64) DEFAULT '', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted bit(1) NOT NULL DEFAULT b'0', tenant_id bigint NOT NULL,
PRIMARY KEY (id), UNIQUE KEY uk_health_altitude_area (tenant_id, area_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='经核实的区划海拔';
CREATE TABLE IF NOT EXISTS health_elderly_spouse (
id bigint NOT NULL AUTO_INCREMENT,
left_profile_id bigint NOT NULL COMMENT '两人中较小老人档案编号',
right_profile_id bigint NOT NULL COMMENT '两人中较大老人档案编号',
confirmed_admin_id bigint NOT NULL COMMENT '核实管理员',
creator varchar(64) DEFAULT '', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater varchar(64) DEFAULT '', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted bit(1) NOT NULL DEFAULT b'0', tenant_id bigint NOT NULL,
PRIMARY KEY (id), UNIQUE KEY uk_health_spouse_pair (tenant_id, left_profile_id, right_profile_id),
KEY idx_health_spouse_right (tenant_id, right_profile_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='老人配偶双向关联';