-- BEGIN CHANGE: historico de cleanup + idempotencia de e-mail de aviso
CREATE TABLE IF NOT EXISTS `z_cleanup_log` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `kind` VARCHAR(16) NOT NULL,
  `ref_id` INT NOT NULL DEFAULT 0,
  `name` VARCHAR(255) NOT NULL DEFAULT '',
  `extra` VARCHAR(255) NOT NULL DEFAULT '',
  `created` INT UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_created_kind` (`created`, `kind`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `z_cleanup_mail` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `account_id` INT NOT NULL,
  `kind` VARCHAR(32) NOT NULL DEFAULT 'player_inactivity',
  `deadline` INT UNSIGNED NOT NULL,
  `player_names` TEXT NOT NULL,
  `email` VARCHAR(255) NOT NULL DEFAULT '',
  `sent_at` INT UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_notify` (`account_id`, `kind`, `deadline`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- END CHANGE
