Migrating Mambo To WordPress

mambo-to-wordpress2

Due to the simple nature of the Mambo DB schema, the migration was pretty straightforward.

Here’s the sql used for the conversion which was modified from this post:


# POSTS
INSERT INTO wp3test.wp_posts
(ID, post_author, post_date, post_content, post_title, post_excerpt,
post_modified, post_type, post_status)
SELECT DISTINCT
        id `ID`,
        created_by `post_author`,
        created `post_date`,
        CONCAT(`introtext`,`fulltext`) `post_content`,
        title `post_title`,
        introtext `post_excerpt`,
        modified `post_modified`,
        'post' `post_type`,
        IF(state = 1, 'publish', 'private') `post_status`
FROM `bluebook`.mos_content



# AUTHORS
INSERT IGNORE INTO wp3.wp_users
  (ID, user_login, user_pass, user_nicename, user_email, user_registered, user_status, display_name)

SELECT DISTINCT
  id `ID`,
  username `user_login`,
  "$P$B4lhk3fR6NAs5z7weWIMJzubwhHH0/0" `user_pass`,
  name `user_nicename`,
  email `user_email`,
  registerDate `user_registered`,
  block `user_status`,
  name `display_name`

FROM `bluebook`.mos_users

;


# MOS_SECTIONS -> CATEGORIES
#wp_terms
INSERT INTO wp3test.wp_terms
  (term_id,name,slug)
SELECT DISTINCT
id `term_id`,
name `name`,
lcase(name) `slug`

FROM `bluebook`.`mos_sections`
WHERE id !=1 AND id !=2


# wp_term_taxonomy
INSERT INTO wp3test.wp_term_taxonomy
  (term_taxonomy_id,term_id,taxonomy)

SELECT DISTINCT
id `term_taxonomy_id`,
id `term_id`,
lcase('category') `taxonomy`

FROM `bluebook`.`mos_sections`
WHERE id !=1 AND id !=2



#wp_term_relationships
INSERT INTO wp3test.wp_term_relationships
  (object_id,term_taxonomy_id)

SELECT DISTINCT
id `object_id`,
sectionid `term_taxonomy_id`

FROM `bluebook`.`mos_content`


# MOS_CATEGORIES -> TAGS
# Thankfully the seciondid and catid values don't match at all

INSERT IGNORE INTO wp3test.wp_terms
  (term_id,name,slug)
SELECT DISTINCT
id `term_id`,
name `name`,
REPLACE(lcase(name),' - ','-') `slug`

FROM `bluebook`.`mos_categories`

WHERE id !=1 AND id !=2


INSERT IGNORE INTO wp3test.wp_term_taxonomy
  (term_taxonomy_id,term_id,taxonomy)

SELECT DISTINCT
id `term_taxonomy_id`,
id `term_id`,
lcase('post-tag') `taxonomy`

FROM `bluebook`.`mos_categories`
WHERE id !=1 AND id !=2


INSERT IGNORE INTO wp3test.wp_term_relationships
  (object_id,term_taxonomy_id)

SELECT DISTINCT
id `object_id`,
catid `term_taxonomy_id`

FROM `bluebook`.`mos_content`


# Update tag and category counts
UPDATE wp_term_taxonomy tt
    SET `count` = (
        SELECT COUNT(tr.object_id)
        FROM wp_term_relationships tr
        WHERE tr.term_taxonomy_id = tt.term_taxonomy_id
    )