Файл: new_top/sql/migrate_all.sql
Строк: 101
-- Extended advertising system
ALTER TABLE `ads`
ADD COLUMN IF NOT EXISTS
`position` varchar(32) NOT NULL DEFAULT 'home_top' AFTER `id`,
ADD COLUMN
IF NOT EXISTS `user_id` int UNSIGNED NOT NULL DEFAULT 0 AFTER `position`,
ADD COLUMN IF NOT EXISTS `status` tinyint NOT NULL DEFAULT 1 COMMENT
'0=pending,1=active,2=rejected,3=expired' AFTER `user_id`,
ADD COLUMN IF
NOT EXISTS `text` varchar(200) NOT NULL DEFAULT '' AFTER `name`,
ADD
COLUMN IF NOT EXISTS `admin_note` varchar(200) NOT NULL DEFAULT '' AFTER
`text`;
CREATE TABLE IF NOT EXISTS `ad_prices` (
`position` varchar(32)
NOT NULL,
`title` varchar(80) NOT NULL DEFAULT '',
`price_day`
decimal(10,2) NOT NULL DEFAULT 0.00,
`enabled` tinyint(1) NOT NULL
DEFAULT 1,
`sort` int NOT NULL DEFAULT 0,
PRIMARY KEY (`position`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT
IGNORE INTO `ad_prices` (`position`, `title`, `price_day`, `enabled`,
`sort`) VALUES
('home_top', 'Главная — верх', 50.00, 1,
10),
('home_bottom', 'Главная — низ', 30.00, 1,
20),
('cat_top', 'Категории — верх', 25.00, 1,
30),
('stats_top', 'Статистика — верх', 20.00, 1,
40),
('global_footer', 'Подвал на всех страницах',
40.00, 1, 50);
CREATE TABLE IF NOT EXISTS `ip_ban` (
`ip` varchar(45) NOT
NULL,
`reason` varchar(200) NOT NULL DEFAULT '',
`until_time` int
UNSIGNED NOT NULL DEFAULT 0,
`time_add` int UNSIGNED NOT NULL DEFAULT 0,
`admin_id` int UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`ip`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE
TABLE IF NOT EXISTS `cheat_log` (
`id` bigint UNSIGNED NOT NULL
AUTO_INCREMENT,
`pf` int UNSIGNED NOT NULL DEFAULT 0,
`ip` varchar(45)
NOT NULL DEFAULT '',
`ua` varchar(255) NOT NULL DEFAULT '',
`kind`
varchar(10) NOT NULL DEFAULT 'hit',
`reason` varchar(32) NOT NULL DEFAULT
'',
`time` int UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY
`time` (`time`),
KEY `ip` (`ip`),
KEY `reason` (`reason`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER
TABLE platforms
ADD COLUMN IF NOT EXISTS style_big tinyint UNSIGNED NOT
NULL DEFAULT 1,
ADD COLUMN IF NOT EXISTS style_small tinyint UNSIGNED NOT
NULL DEFAULT 1;
CREATE TABLE IF NOT EXISTS `news` (
`id` int UNSIGNED NOT
NULL AUTO_INCREMENT,
`title` varchar(150) NOT NULL DEFAULT '',
`text`
text NOT NULL,
`time_add` int UNSIGNED NOT NULL DEFAULT 0,
`active`
tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
KEY `active_time`
(`active`, `time_add`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `rank_snap` (
`pf`
int UNSIGNED NOT NULL,
`day` date NOT NULL,
`rank` int UNSIGNED NOT
NULL DEFAULT 0,
`hs` int UNSIGNED NOT NULL DEFAULT 0,
`ht` int UNSIGNED
NOT NULL DEFAULT 0,
PRIMARY KEY (`pf`, `day`),
KEY `day_rank` (`day`,
`rank`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `news` (
`id` int
UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(150) NOT NULL DEFAULT
'',
`text` text NOT NULL,
`time_add` int UNSIGNED NOT NULL DEFAULT 0,
`active` tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
KEY
`active_time` (`active`, `time_add`)
) ENGINE=InnoDB DEFAULT
CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `user`
ADD COLUMN
IF NOT EXISTS `points` int NOT NULL DEFAULT 0 COMMENT 'баллы' AFTER
`level`;
CREATE TABLE IF NOT EXISTS `points_log` (
`id` bigint UNSIGNED
NOT NULL AUTO_INCREMENT,
`user_id` int UNSIGNED NOT NULL,
`delta` int
NOT NULL,
`balance` int NOT NULL DEFAULT 0,
`reason` varchar(64) NOT
NULL DEFAULT '',
`ref_id` int UNSIGNED NOT NULL DEFAULT 0,
`time` int
UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `user_time`
(`user_id`, `time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `points_config` (
`k` varchar(40) NOT NULL,
`v` varchar(64) NOT NULL DEFAULT '0',
PRIMARY
KEY (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
INSERT IGNORE INTO `points_config` (`k`, `v`)
VALUES
('in_reward', '1'),
('gold_day_cost',
'50'),
('ad_point_per_currency', '1'),
('enabled', '1');