SET @settings_value_is_longtext := (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'settings'
      AND COLUMN_NAME = 'settings_value'
      AND DATA_TYPE = 'longtext'
);

SET @ddl := IF(
    @settings_value_is_longtext = 0,
    'ALTER TABLE settings MODIFY COLUMN settings_value LONGTEXT NULL',
    'SELECT 1'
);

PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
