CREATE TABLE IF NOT EXISTS `tb_auth_credential_key` (
    `id` BIGINT NOT NULL COMMENT 'ID',
    `key_id` VARCHAR(64) NOT NULL COMMENT '密钥标识',
    `public_key_pem` TEXT NOT NULL COMMENT '公钥PEM',
    `encrypted_private_key` TEXT NOT NULL COMMENT '加密后的私钥PEM',
    `fingerprint` VARCHAR(128) NOT NULL COMMENT '公钥指纹',
    `status` VARCHAR(32) NOT NULL COMMENT '状态',
    `rotate_seq` BIGINT NOT NULL COMMENT '轮换序号',
    `parent_key_id` VARCHAR(64) NULL COMMENT '上一密钥标识',
    `transition_payload` TEXT NULL COMMENT '轮换载荷',
    `transition_signature` TEXT NULL COMMENT '轮换签名',
    `not_before` DATETIME NOT NULL COMMENT '生效时间',
    `expires_at` DATETIME NOT NULL COMMENT '过期时间',
    `rotate_at` DATETIME NOT NULL COMMENT '计划轮换时间',
    `previous_until` DATETIME NULL COMMENT '旧密钥保留解密截止时间',
    `created` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `modified` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_auth_credential_key_id` (`key_id`),
    UNIQUE KEY `uk_auth_credential_fingerprint` (`fingerprint`),
    KEY `idx_auth_credential_status` (`status`),
    KEY `idx_auth_credential_rotate_seq` (`rotate_seq`),
    KEY `idx_auth_credential_previous_until` (`previous_until`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='认证传输密钥环';
