<?php
//добавление поля settings в маппинг полей интеграций
$tableName =  $config['table_prefix'] . 'integration_field_mapping';
$tableCheck = run_query("SELECT COUNT(*) as count FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '{$tableName}'");
if($tableCheck['result']->fetch_assoc()['count'] != 0) {
    run_query('ALTER TABLE ' . $tableName . ' ADD COLUMN IF NOT EXISTS `settings` text DEFAULT NULL');
}

//добавление поля button_id в интеграции
$tableName =  $config['table_prefix'] . 'integration_connectors';
$tableCheck = run_query("SELECT COUNT(*) as count FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '{$tableName}'");
if($tableCheck['result']->fetch_assoc()['count'] != 0) {
    run_query('ALTER TABLE ' . $tableName . ' ADD COLUMN IF NOT EXISTS `button_id` INT(11) NOT NULL DEFAULT 0 AFTER `cron_id`');
}