<?php
if (self::$db_alter->fetch_table_info('dbtech_vbmail_keyword'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_keyword` CHANGE `active` `active` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_keyword` CHANGE `active` `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	self::report('Altered Table', 'dbtech_vbmail_keyword');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_mailinglist'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `active` `active` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `active` `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `type` `type` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `type` `type` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'");
	
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `external` `external` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_mailinglist` CHANGE `external` `external` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'");	
	self::report('Altered Table', 'dbtech_vbmail_mailinglist');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_message'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_message` CHANGE `bounce` `bounce` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_message` CHANGE `bounce` `bounce` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	
	//self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_message` CHANGE `handled` `handled` CHAR(1)");
	//self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_message` CHANGE `handled` `handled` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'");
	self::report('Altered Table', 'dbtech_vbmail_message');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_subscription'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_subscription` CHANGE `subscribed` `subscribed` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_subscription` CHANGE `subscribed` `subscribed` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	self::report('Altered Table', 'dbtech_vbmail_subscription');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_subscriptionkeyword'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_subscriptionkeyword` CHANGE `subscribed` `subscribed` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_subscriptionkeyword` CHANGE `subscribed` `subscribed` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	self::report('Altered Table', 'dbtech_vbmail_subscriptionkeyword');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_template'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_template` CHANGE `permanent` `permanent` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_template` CHANGE `permanent` `permanent` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	self::report('Altered Table', 'dbtech_vbmail_template');
}

if (self::$db_alter->fetch_table_info('dbtech_vbmail_user'))
{
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_user` CHANGE `dbtech_vbmail_defaultkeyword` `dbtech_vbmail_defaultkeyword` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_user` CHANGE `dbtech_vbmail_defaultkeyword` `dbtech_vbmail_defaultkeyword` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
	
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_user` CHANGE `dbtech_vbmail_bounceflag` `dbtech_vbmail_bounceflag` CHAR(1)");
	self::$db->query_write("ALTER TABLE `" . TABLE_PREFIX  . "dbtech_vbmail_user` CHANGE `dbtech_vbmail_bounceflag` `dbtech_vbmail_bounceflag` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'");
	self::report('Altered Table', 'dbtech_vbmail_user');
}

self::$db->query_write("
	CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX  . "dbtech_vbmail_subscriptionlog` (
		`subscriptionlogid` int(10) unsigned NOT NULL AUTO_INCREMENT,
		`userid` int(10) unsigned NOT NULL DEFAULT '0',
		`mailinglistid` int(10) unsigned NOT NULL DEFAULT '0',
		`mailid` int(10) unsigned NOT NULL DEFAULT '0',
		`dateline` int(10) unsigned NOT NULL DEFAULT '0',
		`subscribed` tinyint(1) unsigned NOT NULL DEFAULT '1',
		`reason` varchar(50) NOT NULL DEFAULT '',
		PRIMARY KEY (`subscriptionlogid`),
		KEY (`userid`),
		KEY (`mailinglistid`),
		KEY (`mailid`)
	) ENGINE=MyISAM 
");
self::report('Created Table', 'dbtech_vbmail_user');
?>