create table TEXT (
   ID mediumint(9) not null,
   WEBLOG_ID mediumint(9),
   DAY varchar(10),
   TOPIC varchar(128),
   PROTOTYPE varchar(20),
   STORY_ID mediumint(9),
   PARENT_ID mediumint(9),
   TITLE mediumtext,
   TEXT mediumtext,
   ISONLINE tinyint(1),
   EDITABLEBY tinyint(1),
   AUTHOR mediumint(9),
   CREATETIME datetime,
   MODIFYTIME datetime,
   MODIFIER mediumint(9),
   READS bigint,
   IPADDRESS varchar(20),
   unique ID (ID)
);

insert into TEXT (ID,WEBLOG_ID,DAY,TOPIC,PROTOTYPE,TITLE,TEXT,ISONLINE,EDITABLEBY,AUTHOR,CREATETIME,MODIFYTIME,READS) select ID,WEBLOG_ID,DAY,TOPIC,'story',TITLE,TEXT,ISONLINE,EDITABLEBY,AUTHOR,CREATETIME,MODIFYTIME,READS from STORY;
select @offset:=max(ID) from STORY;
insert into TEXT (ID,WEBLOG_ID,DAY,PROTOTYPE,STORY_ID,PARENT_ID,TITLE,TEXT,AUTHOR,CREATETIME,MODIFYTIME,ISONLINE,IPADDRESS) select ID+@offset,WEBLOG_ID,DATE_FORMAT(CREATETIME,'%Y%m%d'),'comment',STORY_ID,PARENT_ID+@offset,TITLE,TEXT,AUTHOR,CREATETIME,MODIFYTIME,ISONLINE,IPADDRESS from COMMENT;
