ALTER TABLE jwipc_srm_test.t_supplier_template_field ADD diy_validate_str varchar(100) NULL COMMENT '动态校验规则' after validate_str;
ALTER TABLE jwipc_srm_test.t_supplier_field ADD diy_validate_str varchar(100) NULL COMMENT '动态校验规则' after validate_str;

CREATE TABLE `t_allowed_character_type` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `field_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字符id',
    `field_label` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字符标签',
    `character_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '字符类型',
    `pattern` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '正则片段',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8mb4 COMMENT='允许字符配置表';

CREATE TABLE `t_regex_rule` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `field_type` varchar(10) NOT NULL COMMENT '字段类别：BASE基础字段，BANK供应商银行',
    `field_id` bigint(20) DEFAULT NULL COMMENT '业务扩展字段id',
    `field_id2` varchar(50) DEFAULT NULL COMMENT '字段id（供应商银行）',
    `field_name` varchar(100) CHARACTER SET utf8 NOT NULL COMMENT '字段名称',
    `currency_type` varchar(10) CHARACTER SET utf8 NOT NULL COMMENT '币种类型',
    `min_length` int(10) DEFAULT NULL COMMENT '最小长度',
    `max_length` int(10) DEFAULT NULL COMMENT '最大长度',
    `fixed_length` int(10) DEFAULT NULL COMMENT '固定长度',
    `validation_msg` varchar(500) CHARACTER SET utf8 DEFAULT NULL COMMENT '校验信息',
    `status` varchar(1) NOT NULL DEFAULT '1' COMMENT '启用状态：1启用，0禁用',
    `create_id` bigint(20) DEFAULT NULL COMMENT '创建人id',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_id` bigint(20) DEFAULT NULL COMMENT '修改人id',
    `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_field_currency` (`field_id`,`currency_type`) COMMENT '业务字段和币种唯一索引',
    UNIQUE KEY `uk_field2_currency` (`field_id2`,`currency_type`)
) ENGINE=InnoDB AUTO_INCREMENT=1962467404080295939 DEFAULT CHARSET=utf8mb4 COMMENT='正则校验规则表';

CREATE TABLE `t_regex_character_relation` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `regex_rule_id` bigint(20) NOT NULL COMMENT '关联t_regex_rules.id',
    `character_type_id` int(11) NOT NULL COMMENT '关联t_allowed_character_type.id',
    `sort_order` int(11) DEFAULT '0' COMMENT '排序字段',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_rule_character` (`regex_rule_id`,`character_type_id`) COMMENT '规则和字符类型唯一索引',
    KEY `character_type_id` (`character_type_id`),
    CONSTRAINT `t_regex_character_relation_ibfk_1` FOREIGN KEY (`regex_rule_id`) REFERENCES `t_regex_rule` (`id`) ON DELETE CASCADE,
    CONSTRAINT `t_regex_character_relation_ibfk_2` FOREIGN KEY (`character_type_id`) REFERENCES `t_allowed_character_type` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1963079112378159109 DEFAULT CHARSET=utf8mb4 COMMENT='规则与字符类型关联表';