Added table prefix option to Drupal migration

It's good practice in the Drupal community to always prefix the tables with something so that if you ever need to host two sites in the same database then you will easily know which tables belongs to which site.

This commit adds an option to the Drupal migration scripts that makes it possible to add such a prefix to the migration query.
This commit is contained in:
Pelle Wessman 2011-08-08 15:22:25 +02:00
parent 72b7b1f056
commit e8f604b5ae
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
# 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"