ALTER TABLE `torrent_config` ADD `use_gzip` ENUM( 'true', 'false' ) DEFAULT 'true' NOT NULL AFTER `cookiepath` ;
ALTER TABLE `torrent_torrents` ADD `private` ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER `banned` ,
ADD `min_ratio` FLOAT( 3 ) UNSIGNED DEFAULT '0.00' NOT NULL AFTER `private` ;
ALTER TABLE `torrent_config` ADD `upload_level` ENUM( 'all', 'user' ) DEFAULT 'user' NOT NULL AFTER `gfx_check` ;
ALTER TABLE `torrent_config` ADD `allow_backup_tracker` ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER `minupload_size_file` ;
ALTER TABLE `torrent_torrents` ADD `backup_tracker` ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER `dht` ;

ALTER TABLE `torrent_config` ADD `allow_html` ENUM( 'true', 'false' ) NOT NULL AFTER `welcome_message` ;

ALTER TABLE `torrent_torrents` ADD `password` VARCHAR( 255 ) AFTER `banned` ;

ALTER TABLE `torrent_config` ADD `torrent_prefix` VARCHAR( 255 ) AFTER `rewrite_engine` ;

ALTER TABLE `torrent_trackers` CHANGE `status` `status` ENUM( 'active', 'dead', 'blacklisted' ) NOT NULL DEFAULT 'active';
ALTER TABLE `torrent_config` ADD `global_min_ratio` FLOAT UNSIGNED DEFAULT '0.00' NOT NULL AFTER `min_share_seed` ;

ALTER TABLE `torrent_users` ADD `banreason` VARCHAR( 255 ) AFTER `newpasswd` ;
ALTER TABLE `torrent_users` ADD `ban` INT( 1 ) UNSIGNED DEFAULT '0' NOT NULL AFTER `active` ;
UPDATE torrent_users SET level = 'user', ban = 1 WHERE level = 'banned';
ALTER TABLE `torrent_users` CHANGE `level` `level` ENUM( 'user', 'premium', 'admin' ) NOT NULL DEFAULT 'user';

ALTER TABLE `torrent_users` ADD `passkey` VARCHAR( 32 ) NULL AFTER `act_key` ;

ALTER TABLE `torrent_users` ADD UNIQUE (
`passkey`
);

CREATE TABLE `torrent_download_completed` (
`user` INT( 11 ) UNSIGNED NOT NULL ,
`torrent` INT( 15 ) UNSIGNED NOT NULL ,
`completed` DATETIME NOT NULL DEFAULT 'NOW()'
) TYPE = MYISAM ;
ALTER TABLE `torrent_download_completed` ADD PRIMARY KEY ( `user` , `torrent` ) ;

ALTER TABLE `torrent_peers` CHANGE `uid` `uid` INT( 11 ) UNSIGNED DEFAULT NULL;
ALTER TABLE `torrent_peers` CHANGE `ip` `ip` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ;
ALTER TABLE `torrent_peers` CHANGE `real_ip` `real_ip` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ;
ALTER TABLE `torrent_download_completed` ADD UNIQUE (
`user` ,
`torrent`
);
ALTER TABLE `torrent_download_completed` ADD INDEX ( `torrent` ) ;

ALTER TABLE `torrent_config` CHANGE `upload_level` `upload_level` ENUM( 'all', 'user', 'premium' ) DEFAULT 'user' NOT NULL;
ALTER TABLE `torrent_torrents` ADD `tracker_list` TEXT AFTER `tracker` ;
UPDATE torrent_config SET version = '0.6';

DROP TABLE `torrent_log`;
CREATE TABLE `torrent_error_log` (
  `id` int(64) NOT NULL default '0',
  `time` timestamp(14) NOT NULL,
  `page` varchar(65) NOT NULL default '',
  `user` int(11) unsigned NOT NULL default '0',
  `ip` int(10) unsigned NOT NULL default '0',
  `host` varchar(255) NOT NULL default '',
  `sql` text,
  `message` text NOT NULL,
  `get_dump` text,
  `post_dump` text,
  `cookie_dump` text,
  PRIMARY KEY  (`id`),
  KEY `page` (`page`)
) TYPE=MyISAM;
ALTER TABLE `torrent_users` CHANGE `lastip` `lastip` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE `torrent_users` CHANGE `lasthost` `lasthost` VARCHAR( 255 ) NOT NULL;
ALTER TABLE `torrent_users` CHANGE `level` `level` ENUM( 'user', 'premium', 'moderator', 'admin' ) DEFAULT 'user' NOT NULL;

ALTER TABLE `torrent_config` DROP `lang_level`;
ALTER TABLE `torrent_config` ADD `announce_text` VARCHAR( 255 ) AFTER `welcome_message` ;
ALTER TABLE `torrent_config` ADD `torrent_complaints` ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER `down_limit` ;
ALTER TABLE `torrent_torrents` CHANGE `info_hash` `info_hash` VARCHAR( 20 ) BINARY DEFAULT NULL;
ALTER TABLE `torrent_torrents` ADD INDEX ( `info_hash` );



ALTER TABLE `torrent_categories` ADD UNIQUE (
`name`
);
ALTER TABLE `torrent_categories` ADD INDEX ( `sort_index` );
ALTER TABLE `torrent_download_completed` DROP INDEX `user` ;
ALTER TABLE `torrent_files` ADD UNIQUE (
`torrent` ,
`filename`
);
ALTER TABLE `torrent_peers` ADD INDEX ( `torrent` , `seeder` );
ALTER TABLE `torrent_peers` ADD UNIQUE (
`torrent` ,
`unique_id`
);
ALTER TABLE `torrent_peers` CHANGE `uid` `uid` INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL ;
DROP TABLE `torrent_download`;
ALTER TABLE `torrent_config`  DROP `max_num_file_day_e`, DROP `max_num_file_week_e`;

ALTER TABLE `torrent_users` ADD `jabber` VARCHAR( 255 ) AFTER `icq` ;
ALTER TABLE `torrent_users` ADD `skype` VARCHAR( 255 ) AFTER `msn` ;

ALTER TABLE `torrent_trackers` ADD `support` ENUM( 'selective', 'global', 'single' ) DEFAULT 'selective' NOT NULL AFTER `url` ;

ALTER TABLE `torrent_online_users` DROP INDEX `id`;
ALTER TABLE `torrent_online_users` ADD PRIMARY KEY ( `id` ) ;

DROP TABLE `torrent_error_log` ;

ALTER TABLE `torrent_config` DROP `use_gzip` ;
ALTER TABLE `torrent_config` DROP `maxupload_day_num` ;
ALTER TABLE `torrent_config` DROP `maxupload_day_share` ;

ALTER TABLE `torrent_private_messages` CHANGE `from` `sender` INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL ;
ALTER TABLE `torrent_private_messages` CHANGE `to` `recipient` INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL;
CREATE TABLE `torrent_private_messages_blacklist` (
  `master` int(11) unsigned NOT NULL default '0',
  `slave` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`master`,`slave`),
  KEY `master` (`master`)
) TYPE=MyISAM;

CREATE TABLE `torrent_private_messages_bookmarks` (
  `master` int(11) unsigned NOT NULL default '0',
  `slave` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`master`,`slave`),
  KEY `master` (`master`)
) TYPE=MyISAM;
ALTER TABLE `torrent_private_messages` CHANGE `read` `is_read` ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL ;

ALTER TABLE `torrent_torrents` DROP INDEX `info_hash_2`;
ALTER TABLE `torrent_torrents` ADD INDEX ( `leechers` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `tot_peer` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `password` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `tracker` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `evidence` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX `rating` ( `numratings` , `ratingsum` );
ALTER TABLE `torrent_torrents` ADD INDEX ( `numfiles` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `downloaded` ) ;
ALTER TABLE `torrent_torrents` DROP INDEX `category_visible` ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `category` ) ;
ALTER TABLE `torrent_torrents` ADD INDEX ( `type` ) ;
ALTER TABLE `torrent_users` ADD INDEX `banned` ( `ban` ) ;