-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql.sql
More file actions
21 lines (19 loc) · 816 Bytes
/
mysql.sql
File metadata and controls
21 lines (19 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE TABLE IF NOT EXISTS `stats` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`item_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`counter_daily` int(11) UNSIGNED NOT NULL DEFAULT '0',
`counter_sum` int(11) UNSIGNED NOT NULL DEFAULT '0',
`created` int(10) UNSIGNED DEFAULT NULL,
`updated` int(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `stats_history` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`stat_id` int(11) UNSIGNED NOT NULL,
`counter` int(11) UNSIGNED NOT NULL,
`date` int(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `stats_history`
ADD CONSTRAINT `stats_history_ibfk_1` FOREIGN KEY (`stat_id`) REFERENCES `stats` (`id`) ON DELETE CASCADE;