use table prefix in bbpress import script
This commit is contained in:
parent
b60bc47a4c
commit
6506c0d900
|
@ -16,6 +16,8 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
BATCH_SIZE ||= 1000
|
BATCH_SIZE ||= 1000
|
||||||
BB_PRESS_PW ||= ENV['BBPRESS_PW'] || ""
|
BB_PRESS_PW ||= ENV['BBPRESS_PW'] || ""
|
||||||
BB_PRESS_USER ||= ENV['BBPRESS_USER'] || "root"
|
BB_PRESS_USER ||= ENV['BBPRESS_USER'] || "root"
|
||||||
|
BB_PRESS_PREFIX ||= ENV['BBPRESS_PREFIX'] || "wp_"
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@ -37,12 +39,12 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
puts "", "importing users..."
|
puts "", "importing users..."
|
||||||
|
|
||||||
last_user_id = -1
|
last_user_id = -1
|
||||||
total_users = bbpress_query("SELECT COUNT(*) count FROM wp_users WHERE user_email LIKE '%@%'").first["count"]
|
total_users = bbpress_query("SELECT COUNT(*) count FROM #{BB_PRESS_PREFIX}users WHERE user_email LIKE '%@%'").first["count"]
|
||||||
|
|
||||||
batches(BATCH_SIZE) do |offset|
|
batches(BATCH_SIZE) do |offset|
|
||||||
users = bbpress_query(<<-SQL
|
users = bbpress_query(<<-SQL
|
||||||
SELECT id, user_nicename, display_name, user_email, user_registered, user_url
|
SELECT id, user_nicename, display_name, user_email, user_registered, user_url
|
||||||
FROM wp_users
|
FROM #{BB_PRESS_PREFIX}users
|
||||||
WHERE user_email LIKE '%@%'
|
WHERE user_email LIKE '%@%'
|
||||||
AND id > #{last_user_id}
|
AND id > #{last_user_id}
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
|
@ -62,7 +64,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
users_description = {}
|
users_description = {}
|
||||||
bbpress_query(<<-SQL
|
bbpress_query(<<-SQL
|
||||||
SELECT user_id, meta_value description
|
SELECT user_id, meta_value description
|
||||||
FROM wp_usermeta
|
FROM #{BB_PRESS_PREFIX}usermeta
|
||||||
WHERE user_id IN (#{user_ids_sql})
|
WHERE user_id IN (#{user_ids_sql})
|
||||||
AND meta_key = 'description'
|
AND meta_key = 'description'
|
||||||
SQL
|
SQL
|
||||||
|
@ -71,7 +73,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
users_last_activity = {}
|
users_last_activity = {}
|
||||||
bbpress_query(<<-SQL
|
bbpress_query(<<-SQL
|
||||||
SELECT user_id, meta_value last_activity
|
SELECT user_id, meta_value last_activity
|
||||||
FROM wp_usermeta
|
FROM #{BB_PRESS_PREFIX}usermeta
|
||||||
WHERE user_id IN (#{user_ids_sql})
|
WHERE user_id IN (#{user_ids_sql})
|
||||||
AND meta_key = 'last_activity'
|
AND meta_key = 'last_activity'
|
||||||
SQL
|
SQL
|
||||||
|
@ -97,7 +99,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
|
|
||||||
categories = bbpress_query(<<-SQL
|
categories = bbpress_query(<<-SQL
|
||||||
SELECT id, post_name, post_parent
|
SELECT id, post_name, post_parent
|
||||||
FROM wp_posts
|
FROM #{BB_PRESS_PREFIX}posts
|
||||||
WHERE post_type = 'forum'
|
WHERE post_type = 'forum'
|
||||||
AND LENGTH(COALESCE(post_name, '')) > 0
|
AND LENGTH(COALESCE(post_name, '')) > 0
|
||||||
ORDER BY post_parent, id
|
ORDER BY post_parent, id
|
||||||
|
@ -119,7 +121,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
last_post_id = -1
|
last_post_id = -1
|
||||||
total_posts = bbpress_query(<<-SQL
|
total_posts = bbpress_query(<<-SQL
|
||||||
SELECT COUNT(*) count
|
SELECT COUNT(*) count
|
||||||
FROM wp_posts
|
FROM #{BB_PRESS_PREFIX}posts
|
||||||
WHERE post_status <> 'spam'
|
WHERE post_status <> 'spam'
|
||||||
AND post_type IN ('topic', 'reply')
|
AND post_type IN ('topic', 'reply')
|
||||||
SQL
|
SQL
|
||||||
|
@ -134,7 +136,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
post_title,
|
post_title,
|
||||||
post_type,
|
post_type,
|
||||||
post_parent
|
post_parent
|
||||||
FROM wp_posts
|
FROM #{BB_PRESS_PREFIX}posts
|
||||||
WHERE post_status <> 'spam'
|
WHERE post_status <> 'spam'
|
||||||
AND post_type IN ('topic', 'reply')
|
AND post_type IN ('topic', 'reply')
|
||||||
AND id > #{last_post_id}
|
AND id > #{last_post_id}
|
||||||
|
@ -155,7 +157,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
posts_likes = {}
|
posts_likes = {}
|
||||||
bbpress_query(<<-SQL
|
bbpress_query(<<-SQL
|
||||||
SELECT post_id, meta_value likes
|
SELECT post_id, meta_value likes
|
||||||
FROM wp_postmeta
|
FROM #{BB_PRESS_PREFIX}postmeta
|
||||||
WHERE post_id IN (#{post_ids_sql})
|
WHERE post_id IN (#{post_ids_sql})
|
||||||
AND meta_key = 'Likes'
|
AND meta_key = 'Likes'
|
||||||
SQL
|
SQL
|
||||||
|
|
Loading…
Reference in New Issue