DROP TABLE IF EXISTS `za_user_family`;
CREATE TABLE `za_user_family`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `name` varchar(200)  NULL COMMENT '家庭名称',
  `primary_guardian_user_id` bigint NOT NULL COMMENT '主要监护人的用户ID，关联za_user表',
  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '逻辑删除标记(0-正常,1-已删除)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  `update_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT NULL COMMENT '修改人',
  `tenant_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci NULL DEFAULT 'Default' COMMENT '租户id',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_primary_guardian_user_id`(`primary_guardian_user_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '我的家庭' ROW_FORMAT = Dynamic;

ALTER TABLE za_user_relation ADD COLUMN family_id INT  NULL COMMENT '家庭id' AFTER `is_default`;