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` TEXT NOT NULL,
  PRIMARY KEY  (`id`)
) TYPE={!type!};

CREATE TABLE `{!prefix!}_admins` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `login` VARCHAR(100) NOT NULL DEFAULT '',
  `password` VARCHAR(40) NOT NULL DEFAULT '',
  PRIMARY KEY  (`id`)
) TYPE={!type!};

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!};

CREATE TABLE `{!prefix!}_config` (
  `config` tinyint(1) NOT NULL DEFAULT 0,
  `pass_len` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
  `points_register` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `points_ref` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  `least_cats` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
  `check_double_email` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `check_double_pass` ENUM('Y','N') NOT NULL DEFAULT 'N',
  `admin_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `url_tlock` BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400',
  `test_text` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `max_tlength` BIGINT(20) UNSIGNED NOT NULL DEFAULT '1000',
  `test_subj` ENUM('Y','N') NOT NULL DEFAULT 'Y',
  `autosend_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY  (`config`)
) TYPE={!type!};

INSERT INTO `{!prefix!}_config` VALUES (0,5,2000,200,5,'Y','N','Y',86400,'Y',1000,'Y','N');

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!};

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!};

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!};

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);

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!};

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` LONGTEXT NOT NULL,
  `receivers` LONGTEXT 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!};

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!};

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);

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!}_config` ADD `max_send` TINYINT(3) UNSIGNED NOT NULL DEFAULT '100';
ALTER TABLE `{!prefix!}_config` ADD `url_blacklist` ENUM('Y','N') NOT NULL DEFAULT 'Y';
ALTER TABLE `{!prefix!}_config` ADD `auto_purge` TINYINT(3) UNSIGNED NOT NULL DEFAULT '14';
ALTER TABLE `{!prefix!}_config` ADD `auto_purge_active` ENUM('Y','N') NOT NULL DEFAULT 'Y';

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

ALTER TABLE `{!prefix!}_config` ADD `last_update` VARCHAR(10) NOT NULL DEFAULT 0;

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!}_config` ADD `unconfirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT '100';
ALTER TABLE `{!prefix!}_config` ADD `profile_lock` BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400';
ALTER TABLE `{!prefix!}_refbanner` ADD `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `{!prefix!}_config` ADD `online_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT '1800';

ALTER TABLE `{!prefix!}_config` ADD `mad_timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `{!prefix!}_config` ADD `mad_count` BIGINT(20) UNSIGNED NOT NULL;
ALTER TABLE `{!prefix!}_config` ADD `profile_update` BIGINT(20) UNSIGNED NOT NULL DEFAULT '15768000';
ALTER TABLE `{!prefix!}_config` ADD `send_prof_update` ENUM('Y','N') NOT NULL DEFAULT 'Y';
ALTER TABLE `{!prefix!}_config` ADD `resend_profile_update` BIGINT(20) UNSIGNED NOT NULL DEFAULT '172800';

ALTER TABLE `{!prefix!}_config` ADD `patch_level` VARCHAR(100) NOT NULL DEFAULT '78';
ALTER TABLE `{!prefix!}_config` ADD `patch_ctime` VARCHAR(10) NOT NULL DEFAULT 0;

ALTER TABLE `{!prefix!}_admins` ADD `email` VARCHAR(255) NOT NULL;

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` LONGTEXT 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`);

ALTER TABLE `{!prefix!}_config` ADD `code_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5;
ALTER TABLE `{!prefix!}_config` ADD `guest_stats` ENUM('MEMBERS','MODULES','INACTIVE') NOT NULL DEFAULT 'MEMBERS';
ALTER TABLE `{!prefix!}_config` ADD `ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5;

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!};

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!}_config` ADD `activate_xchange` BIGINT(20) UNSIGNED NOT NULL DEFAULT 100;
ALTER TABLE `{!prefix!}_config` ADD `order_multi_page` ENUM('Y','N') NOT NULL DEFAULT 'Y';
ALTER TABLE `{!prefix!}_config` ADD `display_refid` ENUM('Y','N') NOT NULL DEFAULT 'Y';
ALTER TABLE `{!prefix!}_config` ADD `ip_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT 86400;
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';
ALTER TABLE `{!prefix!}_config` ADD `allow_direct_pay` ENUM('Y','N') NOT NULL DEFAULT 'N';
