-----------张斌2025-06-16 15:00:00--------------
-----------曲昊东2026-01-05 10:00:00--------------
ALTER TABLE `admin`.`sys_dept`
    ADD COLUMN `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID' AFTER `deleted_at`;
ALTER TABLE `admin`.`sys_role`
    ADD COLUMN `tenant_id` bigint NULL DEFAULT NULL COMMENT '租户ID' AFTER `updated_at`;
-- 模块租户关系表
CREATE TABLE `module_tenant`
(
    `id`           bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `create_by`    bigint unsigned DEFAULT NULL COMMENT '创建者',
    `update_by`    bigint unsigned DEFAULT NULL COMMENT '更新者',
    `created_at`   datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`   datetime DEFAULT NULL COMMENT '更新时间',
    `module_key`   varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模块标识',
    `tenant_id`    bigint unsigned NOT NULL COMMENT '租户ID',
    `expire_at`    datetime                               NOT NULL COMMENT '到期时间',
    `asset_id`     varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '资产ID',
    `asset_sku_id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '资产SKU ID',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_module_tenant` (`module_id`,`tenant_id`) COMMENT '模块ID和租户ID唯一索引',
    KEY            `idx_module_id` (`module_id`) COMMENT '模块ID索引',
    KEY            `idx_tenant_id` (`tenant_id`) COMMENT '租户ID索引',
    KEY            `idx_expire_at` (`expire_at`) COMMENT '到期时间索引'
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='模块租户关系表';