##################################################################################################
## Войдите аккаунт root в phpMyAdmin и дать пользовтелю все привилегии и сделать все запрос SQL ##
##################################################################################################

SET GLOBAL sql_mode = '';
SET SESSION sql_mode = '';
INSERT INTO `bb_config` VALUES ('last_added', '1');
INSERT INTO `bb_config` VALUES ('new_poster', '0');
INSERT INTO `bb_config` VALUES ('limit_poster', '30');
INSERT INTO `bb_config` VALUES ('last_added_excluded', '');
ALTER TABLE `bb_topics` ADD `topic_image` VARCHAR(255) NOT NULL DEFAULT '';
INSERT INTO `bb_cron` VALUES ('', 1, 'Очистка мини постеров', 'clear_poster.php', 'weekly', '1', '06:00:00', 30, '', '', NULL, 0, '', 0, 0, 0);

SET SESSION sql_mode = '';
CREATE TABLE IF NOT EXISTS `bb_warnings` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `type` varchar(100) NOT NULL,
  `type_id` int(11) NOT NULL default '0',
  `user_id` int(11) NOT NULL default '0',
  `poster_id` int(11) NOT NULL default '0',
  `warning` int(3) NOT NULL default '0',
  `time_start` int(11) NOT NULL default '0',
  `time_end` int(11) NOT NULL default '0',
  `term` int(11) default NULL,
  `reason` text,
  `auth` int(1) NOT NULL default '1',
  PRIMARY KEY (`id`)
) ENGINE = MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `bb_users` ADD `user_warnings` TINYINT(3) NOT NULL DEFAULT '0';
INSERT INTO `bb_cron` VALUES ('', '1', 'Warnings', 'warnings.php', 'interval', '', '', '255', '', '', '00:15:00', '1', '', '0', '1', '0');

CREATE TABLE `bb_chat` (
  `id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL default '0',
  `time` int(11) NOT NULL default '0',
  `text` text NOT NULL,
  `text_html` text NOT NULL,
  `ip` char(32) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `bb_vip_tarif` (
  `vip_tar_id` int(10) unsigned NOT NULL auto_increment,
  `vip_tar_name` varchar(120) NOT NULL,
  `vip_tar_time` int(11) NOT NULL,
  `vip_tar_price` int(11) NOT NULL,
  PRIMARY KEY  (`vip_tar_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC AUTO_INCREMENT=6;

INSERT INTO `bb_vip_tarif` (`vip_tar_id`, `vip_tar_name`, `vip_tar_time`, `vip_tar_price`) VALUES
(1, 'Lite', 2592000, 10),
(2, 'Medium', 5184000, 22),
(3, 'Mega', 15552000, 50);

ALTER TABLE `bb_attachments_desc` ADD (
    `thanks` mediumint( 8 ) NOT NULL default '0',
    `rating_sum` int(11) NOT NULL default '0',
    `rating_count` mediumint(8) NOT NULL default '0'
);

CREATE TABLE `bb_attachments_rating` (
    `attach_id` mediumint(8) unsigned NOT NULL default '0',
    `user_id` mediumint(9) NOT NULL default '0',
    `thanked` tinyint(1) NOT NULL default '0',
    `rating` tinyint(1) NOT NULL default '0',
    PRIMARY KEY  (`attach_id`,`user_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `bb_user_view` (
  `user_id` int(11) NOT NULL DEFAULT '0',
  `profile_id` int(11) NOT NULL DEFAULT '0',
  `time` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `bb_config` VALUES ('visit_user', '0');
INSERT INTO `bb_config` VALUES ('visit_user_num', '5');

SET SESSION sql_mode = '';
DROP TABLE IF EXISTS `bb_tags`;
CREATE TABLE IF NOT EXISTS `bb_tags`
(
  `tag_id`   MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `tag_name` VARCHAR(55)           NOT NULL DEFAULT '',
  PRIMARY KEY (`tag_id`),
  FULLTEXT KEY `tag_name` (`tag_name`)
)
  ENGINE = MyISAM
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bb_topic_tags`;
CREATE TABLE IF NOT EXISTS `bb_topic_tags`
(
  `topic_id` MEDIUMINT(8) UNSIGNED NOT NULL,
  `tag_id`   MEDIUMINT(8) UNSIGNED NOT NULL,
  PRIMARY KEY (topic_id, tag_id),
  FOREIGN KEY (topic_id) REFERENCES bb_topics (topic_id) ON DELETE CASCADE,
  FOREIGN KEY (tag_id) REFERENCES bb_tags (tag_id) ON DELETE CASCADE
) ENGINE = MyISAM
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci;

INSERT INTO `bb_cron` VALUES ('', 1, 'Очистка тегов', 'clean_tags.php', 'daily', '', '05:00:00', 30, '', '', '', 0, '', 0, 0, 0);

ALTER TABLE `bb_users` ADD `vip_tarif` MEDIUMINT NOT NULL DEFAULT '0',
ADD `vip_ballance` FLOAT NOT NULL DEFAULT '0',
ADD `vip_start_date` INT NOT NULL DEFAULT '0',
ADD `vip_end_date` INT NOT NULL DEFAULT '0',
ADD `vip_lock` TINYINT NOT NULL DEFAULT '0';

ALTER TABLE `bb_users` ADD `user_vk` varchar(15) NOT NULL DEFAULT '';
ALTER TABLE `bb_users` ADD `user_telegram` varchar(32) NOT NULL DEFAULT '';
ALTER TABLE `bb_users` ADD `user_okru` varchar(15) NOT NULL DEFAULT '';
ALTER TABLE `bb_users` ADD `user_steam` varchar(15) NOT NULL DEFAULT '';

ALTER TABLE `bb_bt_torrents` ADD `last_update` int(11) not null default 0;
ALTER TABLE `bb_bt_torrents` ADD `ext_seeder` int(11) not null default 0;
ALTER TABLE `bb_bt_torrents` ADD `ext_leecher` int(11) not null default 0;

ALTER TABLE `bb_users` ADD COLUMN `user_profile_progress_cur` tinyint(3) NOT NULL DEFAULT '0';
ALTER TABLE `bb_users` ADD COLUMN `user_profile_progress_max` tinyint(3) NOT NULL DEFAULT '0';
ALTER TABLE `bb_users` ADD COLUMN `user_profile_progress_filled` text NOT NULL DEFAULT '';
