text: -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_version (
    `version` varchar(255) NOT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    SELECT CASE WHEN
    (
      SELECT COUNT(*)
      FROM information_schema.tables
      WHERE table_schema = (SELECT DATABASE()) AND table_name LIKE '%zoo_application'
    )
    THEN '' ELSE '3.2.2' END as version;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_application (
    `id` int(11) NOT NULL auto_increment,
    `asset_id` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'FK to the #__assets table.',
    `name` varchar(255) NOT NULL,
    `alias` varchar(255) NOT NULL,
    `application_group` varchar(255) NOT NULL,
    `description` text NOT NULL,
    `params` text NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_category (
    `id` int(11) NOT NULL auto_increment,
    `application_id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    `alias` varchar(255) NOT NULL,
    `description` text NOT NULL,
    `parent` int(11) NOT NULL,
    `ordering` int(11) NOT NULL,
    `published` tinyint(1) NOT NULL,
    `params` text NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ALIAS_INDEX` (`alias`),
    KEY `PUBLISHED_INDEX` (`published`),
    KEY `APPLICATIONID_ID_INDEX` (`application_id`,`published`,`id`),
    KEY `APPLICATIONID_ID_INDEX2` (`application_id`, `id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_category_item (
    `category_id` int(11) NOT NULL,
    `item_id` int(11) NOT NULL,
    PRIMARY KEY (`category_id`,`item_id`),
    KEY `ITEMID_INDEX` (`item_id`),
    KEY `CATEGORYID_INDEX` (`category_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_comment (
    `id` int(11) NOT NULL auto_increment,
    `parent_id` int(11) NOT NULL,
    `item_id` int(11) NOT NULL,
    `user_id` varchar(255) NOT NULL,
    `user_type` varchar(255) NOT NULL,
    `author` varchar(255) NOT NULL,
    `email` varchar(255) NOT NULL,
    `url` varchar(255) NOT NULL,
    `ip` varchar(255) NOT NULL,
    `created` datetime NOT NULL,
    `content` text NOT NULL,
    `state` tinyint(4) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `STATE_INDEX` (`state`),
    KEY `CREATED_INDEX` (`created`),
    KEY `ITEMID_INDEX` (`item_id`),
    KEY `AUTHOR_INDEX` (`author`),
    KEY `ITEMID_STATE_INDEX` (`item_id`, `state`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_item (
    `id` int(11) NOT NULL auto_increment,
    `application_id` int(11) NOT NULL,
    `type` varchar(255) NOT NULL,
    `name` varchar(255) NOT NULL,
    `alias` varchar(255) NOT NULL,
    `created` datetime NOT NULL,
    `modified` datetime NOT NULL,
    `modified_by` int(11) NOT NULL,
    `publish_up` datetime NOT NULL,
    `publish_down` datetime NOT NULL,
    `priority` int(11) NOT NULL,
    `hits` int(11) NOT NULL,
    `state` tinyint(3) NOT NULL,
    `access` int(11) NOT NULL,
    `created_by` int(11) NOT NULL,
    `created_by_alias` varchar(255) NOT NULL,
    `searchable` int(11) NOT NULL,
    `elements` longtext NOT NULL,
    `params` longtext NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ALIAS_INDEX` (`alias`),
    KEY `PUBLISH_INDEX` (`publish_up`,`publish_down`),
    KEY `STATE_INDEX` (`state`),
    KEY `ACCESS_INDEX` (`access`),
    KEY `CREATED_BY_INDEX` (`created_by`),
    KEY `NAME_INDEX` (`name`),
    KEY `APPLICATIONID_INDEX` (`application_id`),
    KEY `TYPE_INDEX` (`type`),
    KEY `MULTI_INDEX` (`application_id`,`access`,`state`,`publish_up`,`publish_down`),
    KEY `MULTI_INDEX2` (`id`,`access`,`state`,`publish_up`,`publish_down`),
    KEY `ID_APPLICATION_INDEX` (`id`,`application_id`),
    FULLTEXT KEY `SEARCH_FULLTEXT` (`name`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_rating (
    `id` int(11) NOT NULL auto_increment,
    `item_id` int(11) default NULL,
    `element_id` varchar(255) default NULL,
    `user_id` int(11) default NULL,
    `value` tinyint(4) default NULL,
    `ip` varchar(255) default NULL,
    `created` datetime default NULL,
    PRIMARY KEY  (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_search_index (
    `item_id` int(11) NOT NULL,
    `element_id` varchar(255) NOT NULL,
    `value` text NOT NULL,
    PRIMARY KEY (`item_id`,`element_id`),
    FULLTEXT KEY `SEARCH_FULLTEXT` (`value`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_submission (
    `id` int(11) NOT NULL auto_increment,
    `application_id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    `alias` varchar(255) NOT NULL,
    `state` tinyint(3) NOT NULL,
    `access` int(11) NOT NULL,
    `params` text NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ALIAS_INDEX` (`alias`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS #__zoo_tag (
    `item_id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    PRIMARY KEY (`item_id`,`name`),
    UNIQUE KEY `NAME_ITEMID_INDEX` (`name`,`item_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  