CREATE TABLE IF NOT EXISTS template_type_option (
    type_code VARCHAR(64) NOT NULL PRIMARY KEY,
    tenant_id BIGINT UNSIGNED NOT NULL DEFAULT 1,
    type_name VARCHAR(128) NOT NULL,
    status VARCHAR(32) NOT NULL DEFAULT 'ENABLED',
    sort_no INT NOT NULL DEFAULT 99,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    KEY idx_tenant_status (tenant_id, status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO template_type_option (type_code, tenant_id, type_name, status, sort_no)
VALUES
    ('AGENDA', 1, '会议日程', 'ENABLED', 1),
    ('SIGN_IN', 1, '签到表', 'ENABLED', 2),
    ('INVITATION', 1, '邀请函', 'ENABLED', 3),
    ('OTHER', 1, '其他', 'ENABLED', 99)
ON DUPLICATE KEY UPDATE
    type_name = VALUES(type_name),
    sort_no = VALUES(sort_no);
