* Added output of (log) messages showing durations of retrievals and updates
408 lines
23 KiB
Text
408 lines
23 KiB
Text
##
|
|
## The Antville Project
|
|
## http://code.google.com/p/antville
|
|
##
|
|
## Copyright 2001-2007 by The Antville People
|
|
##
|
|
## Licensed under the Apache License, Version 2.0 (the ``License'');
|
|
## you may not use this file except in compliance with the License.
|
|
## You may obtain a copy of the License at
|
|
##
|
|
## http://www.apache.org/licenses/LICENSE-2.0
|
|
##
|
|
## Unless required by applicable law or agreed to in writing, software
|
|
## distributed under the License is distributed on an ``AS IS'' BASIS,
|
|
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
## See the License for the specific language governing permissions and
|
|
## limitations under the License.
|
|
##
|
|
## $Revision:3355 $
|
|
## $LastChangedBy:piefke3000 $
|
|
## $LastChangedDate:2007-10-11 15:38:29 +0200 (Thu, 11 Oct 2007) $
|
|
## $URL:https://antville.googlecode.com/svn/trunk/updater/Updater/sql.skin $
|
|
##
|
|
|
|
# Prerequisite for running the updater
|
|
#grant all privileges on `antville`.* to 'antville'@'localhost';
|
|
|
|
<% #test %>
|
|
#!imageTable
|
|
|
|
<% #size %>
|
|
delete from AV_IMAGE where IMAGE_PROTOTYPE <> "LayoutImage" and IMAGE_CREATETIME < str_to_date('2008-01-01', '%Y-%m-%d');
|
|
delete from AV_TEXT where TEXT_CREATETIME < str_to_date('2008-01-01', '%Y-%m-%d');
|
|
|
|
<% #legacy %>
|
|
alter table AV_SITE drop column SITE_TAGLINE, drop column SITE_USERMAYCONTRIB, drop column SITE_HASDISCUSSIONS, drop column SITE_SHOWDAYS, drop column SITE_SHOWARCHIVE, drop column SITE_LANGUAGE, drop column SITE_COUNTRY, drop column SITE_TIMEZONE, drop column SITE_LONGDATEFORMAT, drop column SITE_SHORTDATEFORMAT, drop column SITE_BGCOLOR, drop column SITE_TEXTFONT, drop column SITE_TEXTCOLOR, drop column SITE_TEXTSIZE, drop column SITE_LINKCOLOR, drop column SITE_ALINKCOLOR, drop column SITE_VLINKCOLOR, drop column SITE_TITLEFONT, drop column SITE_TITLECOLOR, drop column SITE_TITLESIZE, drop column SITE_SMALLFONT, drop column SITE_SMALLCOLOR, drop column SITE_SMALLSIZE;
|
|
alter table AV_POLL drop column POLL_TITLE, drop column POLL_ISONLINE;
|
|
delete from AV_IMAGE where IMAGE_ID = 686854;
|
|
|
|
<% #jsonize %>
|
|
select id, xml, metadata from <% param.value1 %> order by id
|
|
|
|
<% #tag %>
|
|
CREATE TABLE `tag` (
|
|
`id` int(11) NOT NULL default '0',
|
|
`name` varchar(255) default NULL,
|
|
`site_id` int(11) default NULL,
|
|
`type` enum('Story','Image') default NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `tags` (`site_id`,`type`,`name`(1)),
|
|
KEY `type` (`type`),
|
|
KEY `name` (`name`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
|
|
|
<% #tag_hub %>
|
|
CREATE TABLE `tag_hub` (
|
|
`id` int(11) NOT NULL default '0',
|
|
`tag_id` int(11) default NULL,
|
|
`tagged_id` int(11) default NULL,
|
|
`tagged_type` enum('Story','Image') default NULL,
|
|
`user_id` int(11) default NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `tagged` (`tagged_id`, `tagged_type`),
|
|
KEY `tags` (`tag_id`,`tagged_type`,`tagged_id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
|
|
|
<% #log %>
|
|
CREATE TABLE `log` (
|
|
`id` int(11) NOT NULL auto_increment,
|
|
`context_id` mediumint(10) default NULL,
|
|
`context_type` varchar(20) default NULL,
|
|
`referrer` mediumtext,
|
|
`action` varchar(255) default NULL,
|
|
`ip` varchar(20) default NULL,
|
|
`created` datetime default NULL,
|
|
`creator_id` mediumint(10) default NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `entries` (`context_type`(5),`action`(5),`created`),
|
|
KEY `requests` (`context_type`(5),`context_id`,created,`action`(5))
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
|
|
|
<% #AV_ACCESSLOG %>
|
|
alter table AV_ACCESSLOG rename log;
|
|
lock tables log write;
|
|
delete from log where ACCESSLOG_DATE < curdate();
|
|
alter table log drop index IDX_ACCESSLOG_MIXED;
|
|
alter table log add column `creator_id` mediumint(10), add column `action` varchar(255), add column `context_type` varchar(20);
|
|
alter table log change column ACCESSLOG_ID id int(11), change column ACCESSLOG_REFERRER referrer mediumtext, change column ACCESSLOG_DATE created datetime, change column ACCESSLOG_F_SITE context_id mediumint(10);
|
|
#alter table log change column ACCESSLOG_IP ip varchar(20);
|
|
create index entries on log (context_type(5), action(5), created);
|
|
create index requests on log (context_type(5), context_id, created, action(5));
|
|
update log set context_type = 'Story', context_id = ACCESSLOG_F_TEXT where ACCESSLOG_F_TEXT is not null;
|
|
update log set context_type = 'Site' where ACCESSLOG_F_TEXT is null;
|
|
update log set creator_id = 0;
|
|
update log set action = 'main';
|
|
alter table log drop column ACCESSLOG_F_TEXT, drop column ACCESSLOG_BROWSER, drop column ACCESSLOG_IP;
|
|
alter table log convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #AV_CHOICE %>
|
|
alter table AV_CHOICE rename choice;
|
|
lock tables choice write;
|
|
alter table choice drop index IDX_CHOICE_F_POLL;
|
|
alter table choice change column CHOICE_ID id mediumint(10), change column CHOICE_F_POLL poll_id mediumint(10), change column CHOICE_TITLE title varchar(255), change column CHOICE_CREATETIME created datetime, change column CHOICE_MODIFYTIME modified datetime;
|
|
create index poll_id on choice (poll_id);
|
|
alter table choice convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #AV_FILE %>
|
|
alter table AV_FILE rename file;
|
|
lock tables file write;
|
|
alter table file drop index IDX_FILE_F_SITE, drop index IDX_FILE_ALIAS, drop index IDX_FILE_F_USER_CREATOR;
|
|
alter table file add column `metadata` mediumtext, add column `parent_id` mediumint(10), add column `parent_type` varchar(30), add column `prototype` varchar(30);
|
|
alter table file change column FILE_ID id mediumint(10), change column FILE_F_SITE site_id mediumint(10), change column FILE_ALIAS name varchar(255), change column FILE_REQUESTCNT requests mediumint(10), change column FILE_CREATETIME created datetime, change column FILE_MODIFYTIME modified datetime, change column FILE_F_USER_CREATOR creator_id mediumint(10), change column FILE_F_USER_MODIFIER modifier_id mediumint(10);
|
|
create index site_id on file (site_id);
|
|
create index creator_id on file (creator_id);
|
|
create index name on file (name(20));
|
|
create index prototype on file (prototype(10));
|
|
create index files on file (parent_id, parent_type, created desc);
|
|
#!files
|
|
alter table file drop column FILE_MIMETYPE, drop column FILE_NAME, drop column FILE_SIZE, drop column FILE_DESCRIPTION;
|
|
alter table file convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #files %>
|
|
select id, FILE_MIMETYPE as type, FILE_SIZE as size,
|
|
FILE_DESCRIPTION as description from file order by id
|
|
|
|
<% #AV_IMAGE %>
|
|
#!imageTable
|
|
lock tables AV_IMAGE write, AV_IMAGE as i read, AV_IMAGE as t read, image write, tag write, tag_hub write, AV_SITE as site read, AV_LAYOUT as layout read, AV_LAYOUT as parent read;
|
|
insert into image select IMAGE_ID, IMAGE_F_SITE, IMAGE_PROTOTYPE, IMAGE_ALIAS, IMAGE_CREATETIME, IMAGE_F_USER_CREATOR, IMAGE_MODIFYTIME, IMAGE_F_USER_MODIFIER, null, null, null, IMAGE_TOPIC, IMAGE_F_IMAGE_PARENT, IMAGE_F_LAYOUT from AV_IMAGE;
|
|
create index topic on image (topic);
|
|
#!images
|
|
create index prototype on image (prototype(10));
|
|
update image set parent_type = 'Site' where prototype = 'Image';
|
|
update image set parent_type = 'Layout' where prototype = 'LayoutImage';
|
|
update image set prototype = "Image" where prototype = "LayoutImage";
|
|
update image set parent_id = site_id where site_id is not null and parent_id is null;
|
|
update image set parent_id = IMAGE_F_LAYOUT where IMAGE_F_LAYOUT is not null and parent_id is null;
|
|
#!layoutImages
|
|
drop table AV_IMAGE;
|
|
delete from image where IMAGE_F_IMAGE_PARENT is not null;
|
|
alter table image drop column topic, drop column IMAGE_F_IMAGE_PARENT, drop column IMAGE_F_LAYOUT;
|
|
create index site_id on image (site_id);
|
|
create index creator_id on image (creator_id);
|
|
create index name on image (name(20));
|
|
create index images on image (parent_id, parent_type, created desc);
|
|
alter table image convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #imageTable %>
|
|
CREATE TABLE `image` (
|
|
`id` mediumint(10) NOT NULL default '0',
|
|
`site_id` mediumint(10) default NULL,
|
|
`prototype` varchar(30) default NULL,
|
|
`name` varchar(255) default NULL,
|
|
`created` datetime default NULL,
|
|
`creator_id` mediumint(10) default NULL,
|
|
`modified` datetime default NULL,
|
|
`modifier_id` mediumint(10) default NULL,
|
|
`parent_id` varchar(20) default NULL,
|
|
`parent_type` varchar(30) default NULL,
|
|
`metadata` mediumtext,
|
|
`topic` varchar(255),
|
|
`IMAGE_F_IMAGE_PARENT` mediumint(10) default NULL,
|
|
`IMAGE_F_LAYOUT` mediumint(10) default NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM AUTO_INCREMENT=831 DEFAULT CHARSET=utf8;
|
|
|
|
<% #images %>
|
|
select i.IMAGE_ID as id, i.IMAGE_ALIAS as name, i.IMAGE_FILENAME as fileName, i.IMAGE_FILEEXT as type,
|
|
i.IMAGE_WIDTH as width, i.IMAGE_HEIGHT as height, i.IMAGE_ALTTEXT as description,
|
|
i.IMAGE_FILESIZE as size, t.IMAGE_WIDTH as thumbnailWidth,
|
|
t.IMAGE_HEIGHT as thumbnailHeight from AV_IMAGE i left join AV_IMAGE t on
|
|
i.IMAGE_F_IMAGE_THUMB = t.IMAGE_ID where i.IMAGE_WIDTH is not null and
|
|
i.IMAGE_HEIGHT is not null and i.IMAGE_F_IMAGE_PARENT is null order by id
|
|
|
|
<% #layoutImages %>
|
|
select site.SITE_ID as site_id, SITE_ALIAS as site_name, parent.LAYOUT_ALIAS as
|
|
parent_name, layout.LAYOUT_ID as layout_id, layout.LAYOUT_ALIAS as layout_name,
|
|
id, name, layout.LAYOUT_F_USER_CREATOR as creator_id,
|
|
layout.LAYOUT_CREATETIME created, metadata
|
|
from image, AV_LAYOUT layout, AV_LAYOUT parent, AV_SITE site where
|
|
SITE_F_LAYOUT = layout.LAYOUT_ID and layout.LAYOUT_F_LAYOUT_PARENT =
|
|
parent.LAYOUT_ID and IMAGE_F_IMAGE_PARENT is null and (IMAGE_F_LAYOUT =
|
|
parent.LAYOUT_ID) # and site.SITE_ID = 3
|
|
|
|
<% #AV_LAYOUT %>
|
|
alter table AV_LAYOUT rename layout;
|
|
lock tables layout write;
|
|
alter table layout add column metadata mediumtext;
|
|
alter table layout change column LAYOUT_PREFERENCES xml mediumtext, change column LAYOUT_ID id mediumint(10), change column LAYOUT_ALIAS name varchar(30), change column LAYOUT_F_SITE site_id mediumint(10), change column LAYOUT_F_LAYOUT_PARENT layout_id mediumint(10), change column LAYOUT_CREATETIME created datetime, change column LAYOUT_MODIFYTIME modified datetime, change column LAYOUT_F_USER_CREATOR creator_id mediumint(10), change column LAYOUT_F_USER_MODIFIER modifier_id mediumint(10), change column LAYOUT_SHAREABLE mode enum('default','shared');
|
|
create index site_id on layout (site_id);
|
|
#!layouts
|
|
alter table layout drop column xml, drop column LAYOUT_TITLE, drop column LAYOUT_DESCRIPTION, drop column LAYOUT_ISIMPORT;
|
|
alter table layout convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #layouts %>
|
|
select id, LAYOUT_TITLE, LAYOUT_DESCRIPTION, LAYOUT_ISIMPORT,
|
|
metadata from layout
|
|
|
|
<% #AV_MEMBERSHIP %>
|
|
alter table AV_MEMBERSHIP rename membership;
|
|
lock tables membership write;
|
|
alter table membership drop index IDX_MEMBERSHIP_F_SITE, drop index IDX_MEMBERSHIP_F_USER, drop index IDX_MEMBERSHIP_USERNAME;
|
|
alter table membership add column `role` enum('Subscriber','Contributor','Manager','Owner') not null;
|
|
alter table membership change column MEMBERSHIP_ID id mediumint(10), change column MEMBERSHIP_F_SITE site_id mediumint(10), change column MEMBERSHIP_USERNAME name varchar(100), change column MEMBERSHIP_CREATETIME created datetime, change column MEMBERSHIP_F_USER creator_id mediumint(10), change column MEMBERSHIP_MODIFYTIME modified datetime, change column MEMBERSHIP_F_USER_MODIFIER modifier_id mediumint(10);
|
|
create index site_id on membership (site_id);
|
|
create index creator_id on membership(creator_id);
|
|
create index name on membership (name(20));
|
|
create index role on membership(role);
|
|
create index roles on membership (name(20), site_id, role);
|
|
create index memberships on membership (creator_id, site_id, role);
|
|
update membership set role = 'Contributor' where MEMBERSHIP_LEVEL = 9361;
|
|
update membership set role = 'Manager' where MEMBERSHIP_LEVEL = 16383;
|
|
update membership set role = 'Owner' where MEMBERSHIP_LEVEL = 131071;
|
|
alter table membership drop column MEMBERSHIP_LEVEL;
|
|
alter table membership convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #AV_POLL %>
|
|
alter table AV_POLL rename poll;
|
|
lock tables poll write;
|
|
alter table poll drop index IDX_POLL_F_SITE, drop index IDX_POLL_F_USER_CREATOR;
|
|
alter table poll add column `status` enum('closed','open');
|
|
alter table poll change column POLL_ID id mediumint(10), change column POLL_F_SITE site_id mediumint(10), change column POLL_F_USER_CREATOR creator_id mediumint(10), change column POLL_F_USER_MODIFIER modifier_id mediumint(10), change column POLL_QUESTION question mediumtext, change column POLL_CLOSETIME closed datetime, change column POLL_CREATETIME created datetime, change column POLL_MODIFYTIME modified datetime;
|
|
create index site_id on poll (site_id);
|
|
create index creator_id on poll (creator_id);
|
|
create index status on poll (status);
|
|
create index polls on poll (site_id, creator_id, created);
|
|
update poll set status = 'closed';
|
|
update poll set status = 'open' where POLL_CLOSED = 1;
|
|
alter table poll drop column POLL_CLOSED;
|
|
alter table poll convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #AV_SITE %>
|
|
alter table AV_SITE rename site;
|
|
lock tables site write;
|
|
alter table site drop index IDX_SITE_ALIAS, drop index IDX_SITE_F_USER_CREATOR;
|
|
alter table site add column metadata mediumtext, add column `mode` enum('closed','restricted','public','open') not null, add column `status` enum('blocked','regular','trusted') not null;
|
|
alter table site change column SITE_PREFERENCES xml mediumtext, change column SITE_ID id mediumint(10), change column SITE_ALIAS name varchar(30), change column SITE_F_LAYOUT layout_id mediumint(10), change column SITE_F_USER_CREATOR creator_id mediumint(10), change column SITE_F_USER_MODIFIER modifier_id mediumint(10), change column SITE_CREATETIME created datetime, change column SITE_MODIFYTIME modified datetime;
|
|
create index name on site (name(20));
|
|
create index layout_id on site (layout_id);
|
|
create index creator_id on site (creator_id);
|
|
create index status on site (status);
|
|
create index mode on site (mode);
|
|
create index created on site(created);
|
|
create index modified on site (modified);
|
|
create index sites on site (name(20), mode, status);
|
|
update site set mode = 'public';
|
|
update site set mode = 'restricted' where SITE_ISONLINE <> 1;
|
|
update site set status = 'regular';
|
|
update site set status = 'blocked' where SITE_ISBLOCKED = 1;
|
|
update site set status = 'trusted' where SITE_ISTRUSTED = 1;
|
|
#!sites
|
|
alter table site drop column xml, drop column SITE_TITLE, drop column SITE_DISKUSAGE, drop column SITE_EMAIL, drop column SITE_LASTUPDATE, drop column SITE_LASTOFFLINE, drop column SITE_LASTBLOCKWARN, drop column SITE_LASTDELWARN, drop column SITE_LASTPING, drop column SITE_ENABLEPING, drop column SITE_ISONLINE, drop column SITE_ISBLOCKED, drop column SITE_ISTRUSTED;
|
|
alter table site convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #sites %>
|
|
select id, metadata, SITE_EMAIL, SITE_LASTUPDATE, SITE_LASTOFFLINE,
|
|
SITE_LASTBLOCKWARN, SITE_LASTDELWARN, SITE_LASTPING, SITE_ENABLEPING,
|
|
SITE_TITLE, mode from site
|
|
|
|
<% #AV_SKIN %>
|
|
alter table AV_SKIN rename skin;
|
|
lock tables skin write, skin as p_skin write, layout write, site write, site as p_site write;
|
|
alter table skin drop index IDX_SKIN_MIXED;
|
|
alter table skin add column source mediumtext;
|
|
alter table skin change column SKIN_ID id mediumint(10), change column SKIN_F_LAYOUT layout_id mediumint(10), change column SKIN_PROTOTYPE prototype varchar(30), change column SKIN_NAME name varchar(50), change column SKIN_F_USER_CREATOR creator_id mediumint(10), change column SKIN_F_USER_MODIFIER modifier_id mediumint(10), change column SKIN_CREATETIME created datetime, change column SKIN_MODIFYTIME modified datetime;
|
|
create index layout_id on skin (layout_id);
|
|
create index prototype on skin (prototype);
|
|
create index name on skin (name);
|
|
create index skins on skin (name(10), layout_id, prototype);
|
|
update skin set prototype = "Files" where prototype = "FileMgr";
|
|
update skin set prototype = "Images" where prototype = "ImageMgr";
|
|
update skin set prototype = "Layouts" where prototype = "LayoutMgr";
|
|
update skin set prototype = "Members" where prototype = "MemberMgr";
|
|
update skin set prototype = "Polls" where prototype = "PollMgr";
|
|
update skin set prototype = "Skins" where prototype = "SkinMgr";
|
|
update skin set prototype = "Stories" where prototype = "StoryMgr";
|
|
update skin set prototype = "Archive" where prototype = "Day";
|
|
update skin set prototype = "Admin" where prototype = "SysMgr";
|
|
update skin set prototype = "LogEntry" where prototype = "SysLog";
|
|
update skin set prototype = "Tag" where prototype = "Topic";
|
|
update skin set prototype = "Tags" where prototype = "TopicMgr";
|
|
update skin set name = "main" where prototype = "Comment" and name = "toplevel";
|
|
update skin set prototype = "Membership", name = "status" where prototype = "Members" and name = "statusloggedin";
|
|
update skin set prototype = "Membership", name = "login" where prototype = "Members" and name = "statusloggedout";
|
|
update skin set name = "search" where prototype = "Site" and name = "searchbox";
|
|
update skin set name = "stylesheet" where prototype = "Site" and name = "style";
|
|
update skin set name = "date" where prototype = "Story" and name = "dayheader";
|
|
update skin set name = "content" where prototype = "Story" and name = "display";
|
|
update skin set name = "history" where prototype = "Story" and name = "historyview";
|
|
#!skins
|
|
alter table skin drop column SKIN_ISCUSTOM, drop column SKIN_SOURCE;
|
|
alter table skin convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #skins %>
|
|
select skin.id, skin.prototype, skin.name, skin.SKIN_SOURCE as source,
|
|
layout.id as layout_id, layout.name as layout_name, layout.metadata as
|
|
layout_metadata, site.name as site_name, site.layout_id as current_layout,
|
|
(select SKIN_SOURCE from site p_site, skin p_skin where p_site.id = site.id
|
|
and p_skin.layout_id = layout.layout_id and p_skin.prototype = skin.prototype
|
|
and p_skin.name = skin.name) as parent from skin left join layout on
|
|
skin.layout_id = layout.id left join site on layout.site_id = site.id order
|
|
by site_name, layout_name, prototype, name
|
|
|
|
<% #AV_SYSLOG %>
|
|
lock tables log write, user read, site read, AV_SYSLOG read;
|
|
alter table log change id id int(11) not null auto_increment;
|
|
insert into log (context_type, context_id, created, creator_id, action) select 'User', user.id, SYSLOG_CREATETIME, SYSLOG_F_USER_CREATOR, SYSLOG_ENTRY from user, AV_SYSLOG where SYSLOG_OBJECT = user.name and SYSLOG_TYPE = 'user';
|
|
insert into log (context_type, context_id, created, creator_id, action) select 'Site', site.id, SYSLOG_CREATETIME, SYSLOG_F_USER_CREATOR, SYSLOG_ENTRY from site, AV_SYSLOG where SYSLOG_OBJECT = site.name and (SYSLOG_TYPE = 'site' or SYSLOG_TYPE = 'weblog');
|
|
insert into log (context_type, context_id, created, creator_id, action) select 'Root', 1, SYSLOG_CREATETIME, SYSLOG_F_USER_CREATOR, 'setup' from AV_SYSLOG where SYSLOG_TYPE = 'system';
|
|
alter table log change id id int(11) not null;
|
|
drop table AV_SYSLOG;
|
|
unlock tables;
|
|
|
|
<% #AV_TEXT %>
|
|
#!contentTable
|
|
lock tables AV_TEXT read, content write, tag write, tag_hub write;
|
|
insert into content select TEXT_ID, TEXT_F_SITE, TEXT_TOPIC, TEXT_PROTOTYPE, TEXT_F_TEXT_STORY, TEXT_F_TEXT_PARENT, TEXT_CONTENT, TEXT_F_USER_CREATOR, TEXT_CREATETIME, TEXT_MODIFYTIME, TEXT_F_USER_MODIFIER, TEXT_READS, TEXT_ALIAS, null, null, null, null, null, TEXT_ISONLINE, TEXT_EDITABLEBY, TEXT_HASDISCUSSIONS from AV_TEXT;
|
|
create index topic on content (topic);
|
|
#!content
|
|
update content set parent_type = "Story";
|
|
update content set parent_type = "Comment" where parent_id is not null;
|
|
update content set parent_id = story_id where parent_id is null and prototype = "Comment" and parent_type = "Story";
|
|
update content set status = 'closed';
|
|
update content set status = 'public' where TEXT_ISONLINE <> 0 or parent_type = "Comment";
|
|
update content set status = 'shared' where TEXT_EDITABLEBY = 1;
|
|
update content set status = 'open' where TEXT_EDITABLEBY = 2;
|
|
update content set mode = 'hidden' where TEXT_ISONLINE = 1;
|
|
update content set mode = 'featured' where TEXT_ISONLINE = 2;
|
|
update content set comment_mode = 'closed';
|
|
update content set comment_mode = 'open' where TEXT_HASDISCUSSIONS = 1;
|
|
alter table content drop column xml, drop column topic, drop column TEXT_HASDISCUSSIONS, drop column TEXT_ISONLINE, drop column TEXT_EDITABLEBY;
|
|
create index story_id on content (story_id);
|
|
create index parent_id on content (parent_id);
|
|
create index parent_type on content (parent_type);
|
|
create index creator_id on content (creator_id);
|
|
create index requests on content (requests);
|
|
create index status on content (status);
|
|
create index content on content (site_id, prototype, status, mode);
|
|
alter table content convert to character set utf8;
|
|
drop table AV_TEXT;
|
|
unlock tables;
|
|
|
|
<% #contentTable %>
|
|
CREATE TABLE `content` (
|
|
`id` mediumint(10) NOT NULL default '0',
|
|
`site_id` mediumint(10) default NULL,
|
|
`topic` varchar(255) default NULL,
|
|
`prototype` enum('Story','Comment') default NULL,
|
|
`story_id` mediumint(10) default NULL,
|
|
`parent_id` mediumint(10) default NULL,
|
|
`xml` mediumtext,
|
|
`creator_id` mediumint(10) default NULL,
|
|
`created` datetime default NULL,
|
|
`modified` datetime default NULL,
|
|
`modifier_id` mediumint(10) default NULL,
|
|
`requests` mediumint(10) default NULL,
|
|
`name` varchar(255) default NULL,
|
|
`metadata` mediumtext,
|
|
`parent_type` varchar(30) default NULL,
|
|
`status` enum('closed','pending','readonly','public','shared','open') default NULL,
|
|
`mode` enum('hidden','featured') default NULL,
|
|
`comment_mode` enum('closed','readonly','moderated','open') default NULL,
|
|
`TEXT_ISONLINE` tinyint(4) default NULL,
|
|
`TEXT_EDITABLEBY` tinyint(1) default NULL,
|
|
`TEXT_HASDISCUSSIONS` tinyint(1) default NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
|
|
|
<% #AV_USER %>
|
|
alter table AV_USER rename user;
|
|
lock tables user write;
|
|
alter table user drop index IDX_USER_NAME;
|
|
alter table user add column metadata mediumtext default NULL, add column `status` enum('blocked','regular','trusted','privileged') not null, add column hash varchar(32) default NULL, add column salt varchar(12) default NULL;
|
|
alter table user change column USER_ID id mediumint(10), change column USER_NAME name varchar(100), change column USER_EMAIL email varchar(255), change column USER_REGISTERED created datetime, change column USER_LASTVISIT modified datetime;
|
|
create index name on user (name(20));
|
|
create index status on user (status);
|
|
create index email on user (email);
|
|
update user set status = 'regular';
|
|
update user set status = 'blocked' where USER_ISBLOCKED = 1;
|
|
update user set status = 'trusted' where USER_ISTRUSTED = 1;
|
|
update user set status = 'privileged' where USER_ISSYSADMIN = 1;
|
|
update user set salt = conv(floor(0 + (rand() * pow(2, 48))), 10, 16), hash = md5(concat(user_password, salt));
|
|
#!users
|
|
alter table user drop column hash, drop column salt, drop column USER_URL, drop column USER_PASSWORD, drop column USER_EMAIL_ISPUBLIC, drop column USER_ISBLOCKED, drop column USER_ISTRUSTED, drop column USER_ISSYSADMIN;
|
|
alter table user convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #AV_VOTE %>
|
|
alter table AV_VOTE rename vote;
|
|
lock table vote write;
|
|
alter table vote drop index IDX_VOTE_F_POLL, drop index IDX_VOTE_F_USER, drop index IDX_VOTE_F_CHOICE, drop index IDX_VOTE_USERNAME;
|
|
alter table vote change column VOTE_ID id mediumint(10), change column VOTE_F_POLL poll_id mediumint(10), change column VOTE_F_CHOICE choice_id mediumint(10), change column VOTE_F_USER creator_id mediumint(10), change column VOTE_USERNAME creator_name varchar(255), change column VOTE_CREATETIME created datetime, change column VOTE_MODIFYTIME modified datetime;
|
|
create index choice_id on vote (choice_id);
|
|
create index votes on vote (creator_name, poll_id);
|
|
alter table vote convert to character set utf8;
|
|
unlock tables;
|
|
|
|
<% #archive %>
|
|
select * from image, layout, site where image.name = '<% param.value1 %>' and image.parent_type = "Layout" and layout.id = image.parent_id and layout.name = '<% param.value2 %>' and site.id = layout.site_id and site.name = '<% param.value3 %>'
|