protected function _installVersion40() //2.0.0 Beta 1
{
$db = $this->_getDb();
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_category_prefix (
category_id INT UNSIGNED NOT NULL,
prefix_id INT UNSIGNED NOT NULL,
PRIMARY KEY (category_id, prefix_id),
KEY prefix_id (prefix_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_category_watch (
user_id int(10) unsigned NOT NULL,
category_id int(10) unsigned NOT NULL,
notify_on enum('','item') NOT NULL,
send_alert tinyint(3) unsigned NOT NULL,
send_email tinyint(3) unsigned NOT NULL,
include_children tinyint(3) unsigned NOT NULL,
PRIMARY KEY (user_id,category_id),
KEY category_id_notify_on (category_id,notify_on)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_comment_reply (
comment_reply_id int(10) unsigned NOT NULL AUTO_INCREMENT,
comment_id int(10) unsigned NOT NULL,
user_id int(10) unsigned NOT NULL,
username varchar(50) NOT NULL,
comment_reply_date int(10) unsigned NOT NULL,
message mediumtext NOT NULL,
ip_id int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (comment_reply_id),
KEY user_id (user_id),
KEY comment_id_comment_reply_date (comment_id,comment_reply_date)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_custom_field_category (
field_id VARBINARY(25) NOT NULL,
category_id INT NOT NULL,
PRIMARY KEY (field_id, category_id),
KEY category_id (category_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_prefix (
prefix_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
prefix_group_id INT UNSIGNED NOT NULL,
display_order INT UNSIGNED NOT NULL,
materialized_order INT UNSIGNED NOT NULL,
css_class VARCHAR(50) NOT NULL DEFAULT '',
allowed_user_group_ids blob NOT NULL,
PRIMARY KEY (prefix_id),
KEY materialized_order (materialized_order)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_prefix_group (
prefix_group_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
display_order INT UNSIGNED NOT NULL,
PRIMARY KEY (prefix_group_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
// ALTERS
try
{
$db->query("
ALTER TABLE xf_nflj_showcase_category
DROP display_in_list,
DROP allow_item_create_user_group_ids,
DROP INDEX display_in_list,
CHANGE node_id
thread_node_id int unsigned not null default 0,
CHANGE prefix_id
thread_prefix_id int unsigned not null default 0,
ADD last_item int(10) unsigned NOT NULL default '0' AFTER item_count,
ADD last_item_title varchar(100) NOT NULL default '' AFTER last_item,
ADD last_item_id int(10) unsigned NOT NULL default '0' AFTER last_item_title,
ADD category_breadcrumb blob NOT NULL,
ADD prefix_cache MEDIUMBLOB NOT NULL,
ADD require_prefix TINYINT UNSIGNED NOT NULL DEFAULT '0',
ADD field_cache MEDIUMBLOB NOT NULL,
ADD INDEX parent_category_id_lft (parent_category_id,lft),
ADD INDEX lft_rgt (lft,rgt)
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
ALTER TABLE xf_nflj_showcase_comment
ADD username varchar(50) NOT NULL AFTER user_id,
ADD comment_reply_count int(10) unsigned NOT NULL DEFAULT '0',
ADD first_comment_reply_date int(10) unsigned NOT NULL DEFAULT '0',
ADD last_comment_reply_date int(10) unsigned NOT NULL DEFAULT '0',
ADD latest_comment_reply_ids varbinary(100) NOT NULL DEFAULT '',
ADD warning_id int(10) unsigned NOT NULL DEFAULT '0',
ADD warning_message varchar(255) NOT NULL DEFAULT '',
ADD KEY comment_id_comment_date (comment_id,comment_date),
ADD KEY user_id (user_id),
ADD KEY comment_date (comment_date)
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
ALTER TABLE xf_nflj_showcase_item
DROP rating,
DROP vote_count,
CHANGE custom_fields
custom_item_fields MEDIUMBLOB NOT NULL,
ADD rating_count int(10) unsigned NOT NULL DEFAULT '0' AFTER view_count,
ADD rating_sum int(10) unsigned NOT NULL DEFAULT '0' AFTER rating_count,
ADD rating_avg float unsigned NOT NULL DEFAULT '0' AFTER rating_sum,
ADD rating_weighted float unsigned NOT NULL DEFAULT '0' AFTER rating_avg,
ADD prefix_id INT UNSIGNED NOT NULL DEFAULT 0,
ADD last_comment_date INT UNSIGNED NOT NULL DEFAULT 0,
ADD last_review_date INT UNSIGNED NOT NULL DEFAULT 0,
ADD INDEX prefix_id (prefix_id),
ADD INDEX thread_id (thread_id),
ADD INDEX category_last_update (category_id,last_update),
ADD INDEX user_id_last_update (user_id,last_update),
ADD INDEX last_update (last_update),
ADD INDEX category_rating_weighted (category_id, rating_weighted),
ADD INDEX rating_weighted (rating_weighted)
");
}
catch (Zend_Db_Exception $e) {}
try
{
$fields = $db->fetchPairs("
SELECT field_id, category_ids
FROM xf_nflj_showcase_custom_field
WHERE category_ids <> '-1'
");
foreach ($fields AS $fieldId => $categories)
{
$categoryIds = explode(',', $categories);
foreach ($categoryIds AS $categoryId)
{
$db->query("
INSERT IGNORE INTO xf_nflj_showcase_custom_field_category
(field_id, category_id)
VALUES
(?, ?)
", array($fieldId, $categoryId)
);
}
}
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
ALTER TABLE xf_nflj_showcase_custom_field
DROP category_ids,
CHANGE display_group
display_group VARCHAR(25) NOT NULL DEFAULT 'sidebar',
CHANGE field_type
field_type VARCHAR(25) NOT NULL DEFAULT 'textbox',
CHANGE match_type
match_type VARCHAR(25) NOT NULL DEFAULT 'none'
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
INSERT INTO xf_content_type
(content_type, addon_id, fields)
VALUES
('showcase_category', 'NFLJ_Showcase', '')
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
INSERT INTO xf_content_type_field
(content_type, field_name, field_value)
VALUES
('showcase_category', 'permission_handler_class', 'NFLJ_Showcase_ContentPermission_Category'),
('showcase_comment', 'moderator_log_handler_class', 'NFLJ_Showcase_ModeratorLogHandler_Comment'),
('showcase_comment', 'moderation_queue_handler_class', 'NFLJ_Showcase_ModerationQueueHandler_Comment'),
('showcase_comment', 'spam_handler_class', 'NFLJ_Showcase_SpamHandler_Comment'),
('showcase_comment', 'warning_handler_class', 'NFLJ_Showcase_WarningHandler_Comment'),
('showcase_item', 'moderator_log_handler_class', 'NFLJ_Showcase_ModeratorLogHandler_Item'),
('showcase_item', 'spam_handler_class', 'NFLJ_Showcase_SpamHandler_Item'),
('showcase_review', 'moderator_log_handler_class', 'NFLJ_Showcase_ModeratorLogHandler_Review'),
('showcase_review', 'moderation_queue_handler_class', 'NFLJ_Showcase_ModerationQueueHandler_Review'),
('showcase_review', 'spam_handler_class', 'NFLJ_Showcase_SpamHandler_Review'),
('showcase_review', 'warning_handler_class', 'NFLJ_Showcase_WarningHandler_Review')
");
}
catch (Zend_Db_Exception $e) {}
try
{
$categoryIds = $db->fetchCol("SELECT category_id FROM xf_nflj_showcase_category");
XenForo_Model::create('NFLJ_Showcase_Model_CustomField')->rebuildFieldCategoryAssociationCache($categoryIds);
}
catch (Zend_Db_Exception $e) {}
// update comments for username field data!
XenForo_Model::create('NFLJ_Showcase_Model_Comment')->updateCommentUsernameInfo();
// force rebuild category structure!
XenForo_Model::create('NFLJ_Showcase_Model_Category')->rebuildCategoryStructure();
}
protected function _installVersion46() //2.1.0
{
$db = $this->_getDb();
try
{
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_tag (
tag_id int(10) unsigned NOT NULL AUTO_INCREMENT,
tag_text varchar(100) NOT NULL,
created_date int(10) unsigned NOT NULL,
created_user_id int(10) unsigned NOT NULL,
content_count int(10) unsigned DEFAULT '0',
latest_tagged_contents mediumblob,
tag_description text,
target_type varchar(25) NOT NULL DEFAULT '',
target_id int(10) unsigned NOT NULL DEFAULT '0',
target_data mediumblob,
PRIMARY KEY (tag_id),
KEY tag_text (tag_text),
KEY target_type_target_id (target_type,target_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("
CREATE TABLE IF NOT EXISTS xf_nflj_showcase_tagged_content (
tag_id int(10) unsigned NOT NULL,
content_type varchar(25) NOT NULL,
content_id int(10) unsigned NOT NULL,
tagged_user_id int(10) unsigned NOT NULL,
tagged_date int(10) unsigned NOT NULL,
PRIMARY KEY (tag_id,content_type,content_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
");
}
catch (Zend_Db_Exception $e) {}
try
{
$db->query("ALTER TABLE xf_nflj_showcase_item ADD COLUMN item_tags MEDIUMBLOB");
}
catch (Zend_Db_Exception $e) {}
}
protected function _installVersion48() //2.1.1
{
$db = $this->_getDb();
try
{
$db->query("
ALTER TABLE xf_nflj_showcase_category
ADD gallery_options_override tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
ADD gallery_type varchar(25) NOT NULL default '',
ADD gallery_tab1 tinyint(3) UNSIGNED NOT NULL DEFAULT '0'
");
}
catch (Zend_Db_Exception $e) {}
}