Merge pull request #383 from voxpelli/drupal-db-prefix

Added table prefix option to Drupal migration
This commit is contained in:
Tom Preston-Werner 2012-01-21 20:03:09 -08:00
commit 6e921c5852
1 changed files with 15 additions and 10 deletions

View File

@ -14,19 +14,24 @@ module Jekyll
# Reads a MySQL database via Sequel and creates a post file for each post # Reads a MySQL database via Sequel and creates a post file for each post
# in wp_posts that has post_status = 'publish'. This restriction is made # in wp_posts that has post_status = 'publish'. This restriction is made
# because 'draft' posts are not guaranteed to have valid dates. # because 'draft' posts are not guaranteed to have valid dates.
QUERY = "SELECT node.nid, \ QUERY = "SELECT n.nid, \
node.title, \ n.title, \
node_revisions.body, \ nr.body, \
node.created, \ n.created, \
node.status \ n.status \
FROM node, \ FROM node AS n, \
node_revisions \ node_revisions AS nr \
WHERE (node.type = 'blog' OR node.type = 'story') \ WHERE (n.type = 'blog' OR n.type = 'story') \
AND node.vid = node_revisions.vid" AND n.vid = nr.vid"
def self.process(dbname, user, pass, host = 'localhost') def self.process(dbname, user, pass, host = 'localhost', prefix = '')
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8') db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
if prefix != ''
QUERY[" node "] = " " + prefix + "node "
QUERY[" node_revisions "] = " " + prefix + "node_revisions "
end
FileUtils.mkdir_p "_posts" FileUtils.mkdir_p "_posts"
FileUtils.mkdir_p "_drafts" FileUtils.mkdir_p "_drafts"