-- Adminer 4.0.3 MySQL dump

SET NAMES utf8;
SET foreign_key_checks = 0;
SET time_zone = '+02:00';
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `banners`;
CREATE TABLE `banners` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_slovak_ci NOT NULL,
  `url` varchar(255) COLLATE utf8_slovak_ci DEFAULT NULL,
  `linktype` tinyint(4) NOT NULL,
  `file` varchar(255) COLLATE utf8_slovak_ci DEFAULT NULL,
  `width` smallint(6) DEFAULT NULL,
  `height` smallint(6) DEFAULT NULL,
  `code` text COLLATE utf8_slovak_ci,
  `visits` int(11) NOT NULL DEFAULT '0',
  `max_visits` int(11) NOT NULL DEFAULT '0',
  `views` int(11) NOT NULL DEFAULT '0',
  `max_views` int(11) NOT NULL DEFAULT '0',
  `show` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci;


DROP TABLE IF EXISTS `banners_groups`;
CREATE TABLE `banners_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_slovak_ci NOT NULL,
  `show` tinyint(1) NOT NULL,
  `max_banners` tinyint(8) NOT NULL,
  `freezed_banners` tinyint(8) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci;


DROP TABLE IF EXISTS `banners_visits`;
CREATE TABLE `banners_visits` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `banner` int(11) NOT NULL,
  `fingerprint` char(32) COLLATE latin1_bin NOT NULL,
  `ip` char(15) COLLATE latin1_bin NOT NULL,
  `ua` varchar(255) CHARACTER SET utf8 COLLATE utf8_slovak_ci NOT NULL,
  `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `banner` (`banner`),
  CONSTRAINT `banners_visits_ibfk_1` FOREIGN KEY (`banner`) REFERENCES `banners` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;


DROP TABLE IF EXISTS `banner_groups`;
CREATE TABLE `banner_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `banner` int(11) NOT NULL,
  `group` int(11) NOT NULL,
  `order` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `banner_group` (`banner`,`group`),
  KEY `group` (`group`),
  CONSTRAINT `banner_groups_ibfk_1` FOREIGN KEY (`banner`) REFERENCES `banners` (`id`) ON DELETE CASCADE,
  CONSTRAINT `banner_groups_ibfk_2` FOREIGN KEY (`group`) REFERENCES `banners_groups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;

SET foreign_key_checks = 1;