Migrating from Slashcode

This is how I moved over my data from a Slashcode site to Drupal. It worked for me, might work for you, might not.

Slash tables needed, dumpm'!

mysqldump --add-drop-table --opt -c story_topics_rendered journals journals_text users users_info comments comment_text stories story_text topics > SlashTables.sql

need to change the name of the users and comments tables since they are the same in Drupal and Slash.

mysqldump -u -p db > db.sql
cp SlashTables.sql Good_Slash_Tables.sql
perl change.pl (this just changes the name of the users and comments tables)
mysql -u -p db_name < SlashTables.sql

now, go to mysql and make the magic happen

Move over topics,Needs to go into term_data, term_hierarchy

delete from term_data;
insert into term_data (tid,vid,name,description,weight) select tid,2,keyword,textname,0 from topics;
delete from term_hierarchy;
insert into term_hierarchy (tid,parent) select tid,0 from topics;

Move over the Slash users into the Drupal users table.

Move over all users who have, left a comment, written in their journal, logged into the site in the past 18 months (or so). maybe this needs to be done into 3 identical tables, then do a select out of them?

Make Sure we get all the Journals Users (Slash users tables was renamed)

delete from users where uid > 2;
insert into users (uid,name,mail,signature,pass,created,status)
select distinct slash_users.uid, slash_users.nickname, slash_users.realemail,
slash_users.sig, slash_users.passwd, UNIX_TIMESTAMP(users_info.created_at),1
from slash_users, journals, users_info where slash_users.uid > 2 and slash_users.uid = users_info.uid and slash_users.uid = journals.uid;

Make sure we get all the users who have ever left a comment(Slash users tables needs renamed)

insert ignore into users (uid,name,mail,signature,pass,created,status)
select distinct slash_users.uid, slash_users.nickname, slash_users.realemail,
slash_users.sig, slash_users.passwd, UNIX_TIMESTAMP(users_info.created_at),1
from slash_users, users_info, slash_comments where slash_users.uid = slash_comments.uid and slash_users.uid=users_info.uid;

Make sure we get all the users who have logged into the site in the last 18 months(Slash users tables needs renamed)

insert ignore into users (uid,name,mail,signature,pass,created,status)
select distinct slash_users.uid, slash_users.nickname, slash_users.realemail,
slash_users.sig, slash_users.passwd, UNIX_TIMESTAMP(users_info.created_at),1
from slash_users, users_info where users_info.lastaccess > '2007' and
slash_users.uid = users_info.uid;

OK That's the useres, now content.

Move over Journals.

The journals.discussion=comments.sid
combine the damn stupid seperate journals tables
this also messes up the sequences things

select max(stoid) from story_text;
select max(stoid) from stories;

ALTER TABLE stories CHANGE stoid stoid int(20) unsigned DEFAULT '0' NOT NULL;
update journals set id = id+22376;
update journals_text set id = id+22376;
update journals set discussion=5 where discussion IS NULL;

insert into stories
(stoid,uid,time,discussion,tid,sid)
select
id,uid,date,discussion,tid,id
from journals;

insert into story_text
(title,introtext,stoid)
select journals.description,journals_text.article, journals.id
from journals,journals_text where journals_text.id = journals.id;

Move over stories

The DISCUSSION field in the slash_stories table == the SID field in the slash_comments table

delete from node;
delete from node_revisions;

insert into node
(nid,vid,type,title,uid,status,created,changed,comment,promote,moderate,sticky)
select
stories.stoid,stories.stoid,'story',story_text.title,stories.uid,1,UNIX_TIMESTAMP(stories.time),UNIX_TIMESTAMP(stories.time),2,1,0,0
from stories, story_text
where stories.stoid = story_text.stoid;

insert into node_revisions (nid,vid, uid, title, body, teaser,log,timestamp,format)
select stories.stoid,stories.stoid,stories.uid, story_text.title, concat(story_text.introtext,story_text.bodytext), story_text.introtext, 'Imported From Slashcode', UNIX_TIMESTAMP(stories.time),1
from stories, story_text where stories.stoid = story_text.stoid;

make sure to change this number to whatever that id+ was from journals

update node set type = 'blog' where nid > 22376;
update node set promote = 0 where type = 'blog';

fix the Annonymous patron thing

update node set uid = 0 where uid = 1;
update node_revisions set uid = 0 where uid = 1;

update node set uid = 1 where uid = 2;
update node_revisions set uid = 1 where uid = 2;

update node_revisions set body = teaser where body = '';

Now, the comments

delete from comments;

insert into comments (nid,cid,pid,uid,subject,comment,timestamp,score,status,format,thread,name,mail,homepage)
select
stories.stoid,slash_comments.cid,0,slash_comments.uid,slash_comments.subject,comment_text.comment,
UNIX_TIMESTAMP(slash_comments.date),0,0,1,'01/', slash_users.nickname,'none@example.com','http://example.org'
from stories,comment_text,slash_users, slash_comments
where comment_text.cid = slash_comments.cid
and slash_users.uid = slash_comments.uid
and stories.discussion = slash_comments.sid
ON DUPLICATE KEY UPDATE nid= nid+2;

update comments set uid = 0 where uid = 1;
update comments set uid = 1 where uid = 2;

fix the comment count for each node

delete from node_comment_statistics;

insert into node_comment_statistics (nid,comment_count)
select node.nid,count(*) as comment_count
from node,comments
where node.nid = comments.nid
group by comments.nid
order by comment_count desc;

select nid from node order by nid desc limit 1;
select nid from node_revisions order by nid desc limit 1;
select cid from comments order by cid desc limit 1;
select * from sequences;
update sequences set id = 28105 where name = 'node_nid';
update sequences set id = 28105 where name = 'node_revisions_vid';
update sequences set id = 31521 where name = 'comments_cid';
update sequences set id = 110 where name = 'term_data_tid';

delete from term_node;
insert into term_node (tid,nid)
select story_topics_rendered.tid, stories.stoid from story_topics_rendered, stories where story_topics_rendered.stoid=stories.stoid order by stories.stoid;

delete from node_access;
insert into node_access (nid,gid,realm,grant_view,grant_update,grant_delete)
select nid,0,'all',1,0,0 from node;

clear the caches

truncate cache;
truncate cache_content;
truncate cache_filter;
truncate cache_menu;
truncate cache_page;
truncate cache_views;

 
 

Drupal is a registered trademark of Dries Buytaert.