Skip to content

Commit

Permalink
Merge pull request jekyll#383 from voxpelli/drupal-db-prefix
Browse files Browse the repository at this point in the history
Added table prefix option to Drupal migration
  • Loading branch information
mojombo committed Jan 22, 2012
2 parents 574e933 + e8f604b commit 6e921c5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/jekyll/migrators/drupal.rb
Expand Up @@ -14,19 +14,24 @@ module Drupal
# 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
# because 'draft' posts are not guaranteed to have valid dates.
QUERY = "SELECT node.nid, \
node.title, \
node_revisions.body, \
node.created, \
node.status \
FROM node, \
node_revisions \
WHERE (node.type = 'blog' OR node.type = 'story') \
AND node.vid = node_revisions.vid"
QUERY = "SELECT n.nid, \
n.title, \
nr.body, \
n.created, \
n.status \
FROM node AS n, \
node_revisions AS nr \
WHERE (n.type = 'blog' OR n.type = 'story') \
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')

if prefix != ''
QUERY[" node "] = " " + prefix + "node "
QUERY[" node_revisions "] = " " + prefix + "node_revisions "
end

FileUtils.mkdir_p "_posts"
FileUtils.mkdir_p "_drafts"

Expand Down

0 comments on commit 6e921c5

Please sign in to comment.