Update on migration and Disqus Thread Migration tool

Just a quick note on the migration process. I’m still planning on talking about the migration in detail, but I want to wait till I feel confident that most of the bugs are gone and the server is stable. Yesterday my blog crashed pretty quickly after launch with a database connection error. I added the SuperCache plugin (which multiple people had recommended) and it seemed to work well, but sometime around 3AM this morning it went down again. Right now I’m thinking that maybe a micro instance (0.6 gig ram) is a bit too small and I should maybe jump up to the next higher level. I’m researching that now.

Also - I made a small tweak to the script I wrote (and blogged about here) that helps with Disqus migration issues. My previous script would return one row for every row in the input CSV. Now the code only writes to the new CSV when an actual change has happened. This makes the new CSV quite a bit smaller. I’ve pasted the code below, but don’t forget the map UDF needs to be customized for your needs. Enjoy.

<cfscript>
//change to the file disqus gave you
input = "dec4.csv";
//change to the name you want to use for the new file
output = "new4.csv";

//Will be passed the URL. Mod it as you see fit.
function map(s) {
	//fix 2015.raymondcamden etc
	s = replace(s, "2015.raymondcamden.com", "www.raymondcamden.com");
	s = replace(s, "dev2013.raymondcamden.com", "www.raymondcamden.com");
	s = replace(s, "ray.camdenfamily.com", "www.raymondcamden.com");
	//change mode=entry
	//this requires a db call
	if(findNoCase("mode=entry", s)) {
		var id = listLast(s, "=");
		var q = queryExecute("select posted from tblblogentries where id = :id", {id:id}, {datasource:"myblog"});
		//technically this doesn't take into account date offset, but screw it
		var newurl = "http://www.raymondcamden.com/#year(q.posted)#/#month(q.posted)#/#day(q.posted)#/#id#";
		return newurl;
	}
	//wordpress adds / at the very end
	if(right(s,1) == "/") s = mid(s, 1, len(s)-1);
	//change -- to -
	s = replace(s, "--", "-", "all");
	return s;
}

myData = fileOpen(expandPath("./#input#"),"read");
myOutput = fileOpen(expandPath("./#output#"),"write");

while(not fileisEOF(myData)) {
	line = fileReadLine(myData);
	newURL = map(line);
	if(newURL != line) {
		newLine = line & "," & newURL;	
		fileWriteLine(myOutput, newLine);
	}
}
fileClose(myData);
fileClose(myOutput);
writeoutput("Done processing.");
</cfscript>
Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments