CREATE TABLE IF NOT EXISTS `wp_post_ids` (
`ID` int(11) NOT NULL,
`post_id` int(11) NOT NULL AUTO_INCREMENT,
`comment` int(11) NOT NULL,
PRIMARY KEY (`post_id`),
UNIQUE KEY `ID` (`ID`,`comment`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `wp_thread_ids` (
`ID` int(11) NOT NULL,
`thread_id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`thread_id`),
UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
TRUNCATE TABLE wp_thread_ids;
ALTER TABLE wp_thread_ids AUTO_INCREMENT = 6469;
TRUNCATE TABLE wp_post_ids;
ALTER TABLE wp_post_ids AUTO_INCREMENT = 65933;
INSERT INTO wp_thread_ids
(
ID
)
SELECT
ID
FROM wpng_posts
WHERE post_type = 'post';
INSERT INTO wp_post_ids
(
ID,
comment
)
SELECT
ID,
0 AS 'comment'
FROM wpng_posts
WHERE post_type = 'post';
INSERT INTO wp_post_ids
(
ID,
comment
)
SELECT
comment_ID AS 'ID',
1 AS 'comment'
FROM wpng_comments;
-- threads
INSERT INTO xf_thread (thread_id, node_id, title, reply_count, view_count, user_id, username, post_date, sticky, discussion_state, discussion_open, discussion_type, first_post_id, first_post_likes, last_post_date, last_post_id, last_post_user_id, last_post_username, prefix_id)
SELECT wpt.thread_id, 120, wpp.post_title, 0, 0, 4267, COALESCE(u.user_login,'UNKNOWN USER'), UNIX_TIMESTAMP(post_date), 0, 'visible', 1, '', 0, 0, 0, 0, 0, '', 0
FROM wpng_posts AS wpp
INNER JOIN wp_thread_ids wpt ON (wpt.ID = wpp.ID)
LEFT JOIN wpng_users AS u ON (u.ID = wpp.post_author)
WHERE wpp.post_type = 'post'
ON DUPLICATE KEY UPDATE
thread_id = VALUES(thread_id);
-- first posts in threads
INSERT INTO xf_post (post_id, thread_id, user_id, username, post_date, message, ip_id, message_state, attach_count, position, likes, like_users, warning_id, warning_message, last_edit_date, last_edit_user_id, edit_count)
SELECT wpst.post_id, wpt.thread_id, 4267, COALESCE(u.user_login,'UNKNOWN USER'), UNIX_TIMESTAMP(post_date), wpp.post_content, 0, 'visible', 0, 1, 0, 'a:0:{}', 0, '', 0, 0, 0
FROM wpng_posts AS wpp
INNER JOIN wp_thread_ids wpt ON (wpt.ID = wpp.ID)
INNER JOIN wp_post_ids wpst ON (wpst.ID = wpp.ID AND wpst.comment = 0)
LEFT JOIN wpng_users AS u ON (u.ID = wpp.post_author)
WHERE wpp.post_type = 'post'
ON DUPLICATE KEY UPDATE
message = VALUES(message);
-- other posts in threads
INSERT INTO xf_post (post_id, thread_id, user_id, username, post_date, message, ip_id, message_state, attach_count, position, likes, like_users, warning_id, warning_message, last_edit_date, last_edit_user_id, edit_count)
SELECT wpst.post_id, wpt.thread_id, 0, wpc.comment_author, UNIX_TIMESTAMP(comment_date), comment_content, 0, 'visible', 0, 2, 0, 'a:0:{}', 0, '', 0, 0, 0
FROM wpng_comments AS wpc
INNER JOIN wp_thread_ids wpt ON (wpt.ID = wpc.comment_post_ID)
INNER JOIN wp_post_ids wpst ON (wpst.ID = wpc.comment_ID AND wpst.comment = 1)
ON DUPLICATE KEY UPDATE
message = VALUES(message);