<?php 
// Добавляем колонку date_update в modules_clientbase_gpt_vs (если таблица уже создана)

$tableName = $config['table_prefix'] . 'modules_clientbase_gpt_vs';

$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) {

    $columnCheck = run_query("
        SELECT COUNT(*) as count
        FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_SCHEMA = DATABASE()
          AND TABLE_NAME = '{$tableName}'
          AND COLUMN_NAME = 'date_update'
    ");

    if ($columnCheck['result']->fetch_assoc()['count'] == 0) {
        run_query("ALTER TABLE `{$tableName}` ADD COLUMN `date_update` DATETIME DEFAULT NULL");

    }
}