SET @tableExists := (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'nfse_recaptcha'
);

SET @sql := IF(@tableExists = 0,
'CREATE TABLE nfse_recaptcha (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
sitekey VARCHAR(255) DEFAULT NULL,
recaptcha_secret VARCHAR(255) DEFAULT NULL,
tipo VARCHAR(20) DEFAULT "v2",
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;',
'SELECT "Tabela nfse_recaptcha já existe."'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;