Files
itflow/admin/database_updates/4.3.0.php

28 lines
1.5 KiB
PHP

<?php
/*
* ITFlow - Database update to version 4.3.0 (from 4.2.9)
* Included by admin/database_updates.php - do not access directly
*
* Contacts can leave the email sent to many from the contacts or clients list (functions/contact_unsubscribe.php):
* contacts.contact_unsubscribed_at - when they did, by the link in one of those emails, in the client portal or
* through an agent; NULL while they get them. Ticket emails, invoices and the rest still go
* settings.config_mail_unsubscribe_secret - the key the links are signed with, made the first time one is needed
*
* Re-runnable: each column is added only where it isn't there.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
$itflow_unsubscribe_columns = [
['contacts', 'contact_unsubscribed_at', "datetime DEFAULT NULL AFTER `contact_email_bounce`"],
['settings', 'config_mail_unsubscribe_secret', "varchar(64) DEFAULT NULL AFTER `config_mail_send_per_minute`"],
];
foreach ($itflow_unsubscribe_columns as [$itflow_table, $itflow_column, $itflow_definition]) {
$itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$itflow_table' AND COLUMN_NAME = '$itflow_column' LIMIT 1");
if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) {
mysqli_query($mysqli, "ALTER TABLE `$itflow_table` ADD `$itflow_column` $itflow_definition");
}
}