<?php

// Revert
if (self::$db_alter->fetch_table_info('administrator'))
{
	self::$db_alter->drop_field('dbtech_vbmailadminperms');
	self::report('Reverted Table', 'administrator');
}

// Clean up
self::$db->query_write("DELETE FROM `" . TABLE_PREFIX . "datastore` WHERE `title` LIKE 'dbtech_vbmail_%'");
self::report('Reverted Table', 'datastore');

// Revert
if (self::$db_alter->fetch_table_info('user'))
{
	self::$db_alter->drop_field(array(
		'dbtech_vbmail_bounceflag',
		'dbtech_vbmail_defaultkeyword',
		'dbtech_vbmail_inactivereminder',
		'dbtech_vbmail_numreminders'
	));
	self::report('Reverted Table', 'user');
}

// Revert
if (self::$db_alter->fetch_table_info('usergroup'))
{
	self::$db_alter->drop_field('dbtech_vbmailpermissions');
	self::report('Reverted Table', 'usergroup');
}

// Drop
$tables = array(
	'feedback',
	'keyword',
	'mail',
	'mailinglist',
	'message',
	'subscription',
	'subscriptionkeyword',
	'subscriptionlog',
	'template',
	'user',
);
foreach ($tables as $table)
{
	self::$db->query_write("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "dbtech_vbmail_{$table}`");
	self::report('Deleted Table', 'dbtech_vbmail_' . $table);
}