-- Run once in phpMyAdmin for an existing ItuzaFlow installation.
ALTER TABLE scheduled_emails MODIFY status ENUM('Draft','Scheduled','Processing','Sent','Failed','Cancelled') NOT NULL DEFAULT 'Draft', ADD COLUMN attempts TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER status, ADD COLUMN last_error VARCHAR(500) NULL AFTER attempts;
CREATE TABLE IF NOT EXISTS system_settings(id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,company_id BIGINT UNSIGNED NOT NULL,setting_key VARCHAR(100) NOT NULL,setting_value MEDIUMTEXT NULL,encrypted TINYINT(1) NOT NULL DEFAULT 0,updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,UNIQUE KEY settings_company_key(company_id,setting_key),CONSTRAINT settings_company_fk FOREIGN KEY(company_id) REFERENCES companies(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
