ALTER TABLE `{{db_prefix}}articles` ADD `staff_id` INT(11) NOT NULL DEFAULT '0' AFTER `category`;
ALTER TABLE `{{db_prefix}}articles` ADD `last_update` INT(11) NOT NULL DEFAULT '0' AFTER `date`;

ALTER TABLE `{{db_prefix}}canned_response` ADD `date` INT(11) NOT NULL DEFAULT '0' AFTER `position`, ADD `last_update` INT(11) NOT NULL DEFAULT '0' AFTER `date`, ADD `staff_id` INT(11) NOT NULL DEFAULT '0' AFTER `last_update`;

ALTER TABLE `{{db_prefix}}custom_fields` ADD `departments` MEDIUMTEXT NULL DEFAULT NULL AFTER `required`;

ALTER TABLE `{{db_prefix}}departments` CHANGE `type` `private` INT NOT NULL DEFAULT '0';

ALTER TABLE `{{db_prefix}}emails_tpl` CHANGE `orderlist` `position` SMALLINT NOT NULL;
ALTER TABLE `{{db_prefix}}emails_tpl` ADD `last_update` INT(11) NOT NULL DEFAULT '0' AFTER `message`, ADD `status` TINYINT(1) NOT NULL DEFAULT '1' AFTER `last_update`;

RENAME TABLE `{{db_prefix}}knowledgebase_category` TO `{{db_prefix}}kb_category`;

ALTER TABLE `{{db_prefix}}login_log` ADD `success` TINYINT(1) NOT NULL DEFAULT '0' AFTER `agent`;
TRUNCATE TABLE `{{db_prefix}}login_log`;

ALTER TABLE `{{db_prefix}}staff` ADD `token` VARCHAR(255) NULL DEFAULT NULL AFTER `email`;
ALTER TABLE `{{db_prefix}}staff` ADD `registration` INT(11) NOT NULL DEFAULT '0' AFTER `token`;
ALTER TABLE `{{db_prefix}}staff` ADD `active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `status`;

ALTER TABLE `{{db_prefix}}tickets_messages` ADD `staff_id` INT(11) NOT NULL DEFAULT '0' AFTER `customer`;

ALTER TABLE `{{db_prefix}}users` ADD `registration` INT(11) NOT NULL DEFAULT '0' AFTER `password`, ADD `last_login` INT(11) NOT NULL DEFAULT '0' AFTER `registration`, ADD `token` VARCHAR(255) NULL DEFAULT NULL AFTER `last_login`, ADD `avatar` VARCHAR(255) NULL DEFAULT NULL AFTER `token`;

ALTER TABLE `{{db_prefix}}staff` ADD `two_factor` VARCHAR(255) NULL DEFAULT NULL AFTER `avatar`;

CREATE TABLE `{{db_prefix}}ticket_notes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `ticket_id` int NOT NULL,
  `staff_id` int NOT NULL,
  `date` int NOT NULL,
  `message` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;