<?php
$result = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "calc_template LIKE 'type'");
if (!sql_fetch_array($result)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "calc_template ADD type VARCHAR(16) NOT NULL");
}

$result = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "calc_template LIKE 'tpl_name'");
if (!sql_fetch_array($result)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "calc_template ADD tpl_name VARCHAR(100) NOT NULL");
}

run_query("UPDATE " . $config['table_prefix'] . "calc_template SET `type` = 'calc' WHERE ((`id` = '1') OR (`id` = '2') OR (`id` = '3') OR (`id` = '4') OR (`id` = '5'))");
run_query("UPDATE " . $config['table_prefix'] . "calc_template SET `tpl_name` = CONCAT('calc_', `id`, '.tpl') WHERE ((`id` = '1') OR (`id` = '2') OR (`id` = '3') OR (`id` = '4') OR (`id` = '5'))");

$result = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "calc_template LIKE 'javascript_tpl'");
if (!sql_fetch_array($result)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "calc_template ADD javascript_tpl longtext NOT NULL");
}