DROP TABLE IF EXISTS `{!prefix!}admin_menu`;
CREATE TABLE `{!prefix!}admin_menu` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `action` VARCHAR(255) NOT NULL DEFAULT '',
  `what` VARCHAR(255) NULL DEFAULT NULL,
  `title` VARCHAR(50) NOT NULL DEFAULT '',
  `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `descr` BLOB NOT NULL,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}cats`;
CREATE TABLE `{!prefix!}cats` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `cat` VARCHAR(255) NOT NULL DEFAULT '',
  `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}guest_menu`;
CREATE TABLE `{!prefix!}guest_menu` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `action` VARCHAR(255) NOT NULL DEFAULT '',
  `what` VARCHAR(255) NULL DEFAULT NULL,
  `title` VARCHAR(50) NOT NULL DEFAULT '',
  `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}max_receive`;
CREATE TABLE `{!prefix!}max_receive` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `value` MEDIUMINT(9) NOT NULL DEFAULT 0,
  `comment` VARCHAR(255) NOT NULL DEFAULT '',
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}member_menu`;
CREATE TABLE `{!prefix!}member_menu` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `action` VARCHAR(255) NOT NULL DEFAULT '',
  `what` VARCHAR(255) NULL DEFAULT NULL,
  `title` VARCHAR(50) NOT NULL DEFAULT '',
  `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}mod_reg`;
CREATE TABLE `{!prefix!}mod_reg` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `module` VARCHAR(50) NOT NULL DEFAULT '',
  `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `hidden` ENUM('Y','N') NOT NULL DEFAULT 'N',
  `admin_only` ENUM('Y','N') NOT NULL DEFAULT 'N',
  `title` VARCHAR(200) NOT NULL DEFAULT '',
  `mem_only` ENUM('Y','N') NOT NULL DEFAULT 'N',
  `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

INSERT INTO `{!prefix!}mod_reg` VALUES (1,'admin','N','N','Y','','N',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (2,'index','N','N','N','','N',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (3,'frameset','Y','N','N','','N',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (4,'login','N','N','N','','Y',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (6,'frametester','N','Y','N','','N',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (7,'loader','N','Y','N','','N',0);
INSERT INTO `{!prefix!}mod_reg` VALUES (8,'order','N','N','N','','N',0);

DROP TABLE IF EXISTS `{!prefix!}payments`;
CREATE TABLE `{!prefix!}payments` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `time` INT(7) NOT NULL DEFAULT 0,
  `payment` FLOAT(5,3) UNSIGNED NOT NULL DEFAULT '0.000',
  `mail_title` VARCHAR(255) NOT NULL DEFAULT '',
  `price` FLOAT(5,5) UNSIGNED NOT NULL DEFAULT '0.00000',
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}pool`;
CREATE TABLE `{!prefix!}pool` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `sender` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `subject` VARCHAR(200) NOT NULL DEFAULT '',
  `text` LONGBLOB NOT NULL,
  `receivers` LONGBLOB NOT NULL,
  `payment_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
  `data_type` ENUM('TEMP','SEND','NEW','ADMIN') NOT NULL DEFAULT 'TEMP',
  `timestamp` VARCHAR(10) NOT NULL DEFAULT 0,
  `url` TINYTEXT NOT NULL,
  `target_send` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}refbanner`;
CREATE TABLE `{!prefix!}refbanner` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `url` TEXT NOT NULL,
  `alternate` TEXT NOT NULL,
  `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `counter` BIGINT(22) NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}refdepths`;
CREATE TABLE `{!prefix!}refdepths` (
  `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
  `level` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
  `percents` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

INSERT INTO `{!prefix!}refdepths` VALUES (1,0,100);
INSERT INTO `{!prefix!}refdepths` VALUES (2,1,30);
INSERT INTO `{!prefix!}refdepths` VALUES (3,2,15);
INSERT INTO `{!prefix!}refdepths` VALUES (4,3,10);
INSERT INTO `{!prefix!}refdepths` VALUES (5,4,8);
INSERT INTO `{!prefix!}refdepths` VALUES (6,5,5);

DROP TABLE IF EXISTS `{!prefix!}refsystem`;
CREATE TABLE `{!prefix!}refsystem` (
  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
  `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `level` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
  `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

ALTER TABLE `{!prefix!}pool` MODIFY `url` TINYTEXT NOT NULL;
ALTER TABLE `{!prefix!}pool` CHANGE `url` `url` TINYBLOB NOT NULL;
ALTER TABLE `{!prefix!}pool` MODIFY `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP';

INSERT INTO `{!prefix!}mod_reg` VALUES (NULL,'chk_login','N','N','N','','N',0);
ALTER TABLE `{!prefix!}pool` MODIFY `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP';
ALTER TABLE `{!prefix!}refbanner` ADD `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0;

DROP TABLE IF EXISTS `{!prefix!}task_system`;
CREATE TABLE `{!prefix!}task_system` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `assigned_admin` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `status` ENUM('NEW','OPEN','SOLVED','CLOSED','DELETED') NOT NULL DEFAULT 'NEW',
  `task_type` ENUM('FIRST_USER','SUPPORT_MEMBER','SUPPORT_ADMIN','OTHERS','EXTENSION','EXTENSION_UPDATE') NOT NULL DEFAULT 'FIRST_USER',
  `subject` VARCHAR(255) NOT NULL DEFAULT '',
  `text` LONGBLOB NOT NULL,
  `task_created` VARCHAR(10) NOT NULL DEFAULT 0,
  KEY (`assigned_admin`),
  PRIMARY KEY  (`id`)
) TYPE={!type!};

ALTER TABLE `{!prefix!}pool` ADD INDEX (`sender`);
ALTER TABLE `{!prefix!}pool` ADD INDEX (`payment_id`);
ALTER TABLE `{!prefix!}pool` ADD INDEX (`cat_id`);
ALTER TABLE `{!prefix!}refsystem` ADD INDEX (`userid`);
ALTER TABLE `{!prefix!}task_system` ADD INDEX (`assigned_admin`);
ALTER TABLE `{!prefix!}task_system` ADD INDEX (`userid`);

DROP TABLE IF EXISTS `{!prefix!}extensions`;
CREATE TABLE `{!prefix!}extensions` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `ext_name` VARCHAR(255) NOT NULL DEFAULT '',
  `ext_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
  `ext_version` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
  PRIMARY KEY  (`id`)
) TYPE={!type!};

DROP TABLE IF EXISTS `{!prefix!}jackpot`;
CREATE TABLE `{!prefix!}jackpot` (
  `ok` CHAR(2) NOT NULL DEFAULT 'ok',
  `points` FLOAT(20,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY  (`ok`)
) TYPE={!type!};
ALTER TABLE `{!prefix!}pool` ADD `zip` VARCHAR(6) NOT NULL DEFAULT '';

ALTER TABLE `{!prefix!}task_system` CHANGE `task_type` `task_type` VARCHAR(255)  NOT NULL DEFAULT 'FIRST_USER';
