CREATE TABLE IF NOT EXISTS op_emsp_tokens (
    uid VARCHAR(255) PRIMARY KEY,
    auth_id VARCHAR(255),
    issuer VARCHAR(255),
    valid TINYINT(1) DEFAULT 1,
    whitelist VARCHAR(32),
    local_rfid VARCHAR(255),
    status VARCHAR(32) NOT NULL DEFAULT 'valid',
    source VARCHAR(16) NOT NULL DEFAULT 'emsp',
    valid_until DATETIME NULL,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    KEY idx_auth_id (auth_id),
    KEY idx_local_rfid (local_rfid),
    KEY idx_status (status),
    KEY idx_source (source)
) CHARACTER SET utf8mb4;
