CREATE TABLE IF NOT EXISTS `#__djev_cats`
(
    `id`               int(11)                NOT NULL AUTO_INCREMENT,
    `name`             varchar(255)           NOT NULL,
    `alias`            varchar(255)           NOT NULL,
    `icon_type`        enum ('','fa','image') NOT NULL,
    `fa_icon`          varchar(255)           NOT NULL,
    `image_icon`       varchar(255)           NOT NULL,
    `icon_color`       varchar(20)            NOT NULL,
    `icon_bg`          varchar(20)            NOT NULL,
    `description`      text                            DEFAULT NULL,
    `checked_out`      int(11)                NOT NULL DEFAULT '0',
    `checked_out_time` datetime               NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created`          datetime               NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_by`       int(11)                NOT NULL,
    `params`           text                            DEFAULT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_cities`
(
    `id`               int(10) unsigned NOT NULL AUTO_INCREMENT,
    `description`      TEXT             NULL     DEFAULT NULL,
    `published`        tinyint(4)       NOT NULL DEFAULT '1',
    `checked_out`      INT(11)          NOT NULL DEFAULT '0',
    `checked_out_time` DATETIME         NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created`          DATETIME         NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_by`       INT(11)          NOT NULL,
    `params`           TEXT             NULL     DEFAULT NULL,
    `name`             varchar(255)     NOT NULL,
    `alias`            varchar(255)     NOT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_events`
(
    `id`               int(11)             NOT NULL AUTO_INCREMENT,
    `cat_id`           int(11)             NOT NULL,
    `city_id`          int(11)                      DEFAULT NULL,
    `title`            varchar(255)        NOT NULL,
    `alias`            varchar(255)        NOT NULL,
    `intro`            text                         DEFAULT NULL,
    `description`      text                         DEFAULT NULL,
    `published`        tinyint(4)          NOT NULL DEFAULT '0',
    `featured`         tinyint(1) unsigned NOT NULL,
    `price`            varchar(255)        NOT NULL,
    `external_url`     varchar(255)        NOT NULL,
    `location_id`      INT                 NOT NULL DEFAULT '0',
    `location`         varchar(255)        NOT NULL,
    `address`          varchar(255)        NOT NULL,
    `post_code`        varchar(60)         NOT NULL,
    `latitude`         decimal(18, 15)     NOT NULL,
    `longitude`        decimal(18, 15)     NOT NULL,
    `zoom`             tinyint(2) unsigned NOT NULL,
    `time`             text                         DEFAULT NULL,
    `checked_out`      int(11)             NOT NULL DEFAULT '0',
    `checked_out_time` datetime            NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created`          datetime            NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_by`       int(11)             NOT NULL,
    `online_event`     int(11)             NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    KEY `cat_id` (`cat_id`),
    KEY `city_id` (`city_id`),
    KEY `featured` (`featured`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_events_media`
(
    `id`       int(10) unsigned    NOT NULL AUTO_INCREMENT,
    `event_id` int(10) unsigned    NOT NULL DEFAULT '0',
    `poster`   tinyint(1) unsigned NOT NULL DEFAULT '0',
    `title`    varchar(255)                 DEFAULT NULL,
    `image`    varchar(255)        NOT NULL,
    `video`    varchar(255)                 DEFAULT NULL,
    `ordering` int(11)             NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_events_time`
(
    `id`         int(11)    NOT NULL AUTO_INCREMENT,
    `event_id`   int(11)    NOT NULL,
    `start`      datetime   NOT NULL DEFAULT '0000-00-00 00:00:00',
    `start_time` TINYINT(1) NOT NULL DEFAULT '0',
    `end`        datetime   NOT NULL DEFAULT '0000-00-00 00:00:00',
    `end_time`   TINYINT(1) NOT NULL DEFAULT '0',
    `exclude`    tinyint(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    KEY `event_exclude` (`event_id`, `exclude`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_tags`
(
    `id`    int(11)      NOT NULL AUTO_INCREMENT,
    `name`  varchar(255) NOT NULL,
    `alias` varchar(255) NOT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_tags_xref`
(
    `id`       int(11) NOT NULL AUTO_INCREMENT,
    `tag_id`   int(11) NOT NULL,
    `event_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_jtags_xref`
(
    `id`       int(11) NOT NULL AUTO_INCREMENT,
    `tag_id`   int(11) NOT NULL,
    `event_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;

CREATE TABLE IF NOT EXISTS `#__djev_locations`
(
    `id`               int(11)      NOT NULL AUTO_INCREMENT,
    `name`             varchar(255) NOT NULL,
    `alias`            varchar(255) NOT NULL,
    `address`          varchar(255) NOT NULL,
    `city_id`          int(11)      NOT NULL DEFAULT 0,
    `post_code`        varchar(255) NOT NULL,
    `latitude`         varchar(20)  NOT NULL,
    `longitude`        varchar(20)  NOT NULL,
    `description`      text                  DEFAULT NULL,
    `published`        tinyint(4)   NOT NULL DEFAULT '1',
    `checked_out`      int(11)      NOT NULL DEFAULT '0',
    `checked_out_time` datetime     NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created`          datetime     NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_by`       int(11)      NOT NULL,
    `params`           text                  DEFAULT NULL,
    `zoom` tinyint(2) unsigned,
    PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;
