While I was enabling "Views" module in drupal, it acted up. Views did not show up. So, I disabled Views and tried to re-install. But, right after disabling Views, menu is screwed up. Like this.
I couldn't administer menu, modules, and theme any more! That is a disaster for admin user. I was so tempted to re-install drupal, but then, migrating old database to new one is another challenge. Old one was in dev, but we already collected some data. And, old site were configured too.
So, only option is "FIX". But, fixing a software that I never deal with was a quite discouraging moment. I prepared fresh install of drupal, and diff'd the files. Files looked similar. Then, all modification must be in the database.
So, I wrote a database diff tool.
Successfully, I found it is because menu_router table is corrupted. I restored.
Here is the sample code that I used:
#!/usr/bin/env python
import MySQLdb
import os
import sys
def main():
try:
cn1 = MySQLdb.connect(host="172.16.136.114", db="drupal_prod")
cn2 = MySQLdb.connect(host="172.16.136.114", db="drupal_dev")
except:
print >>sys.stderr, "ERROR: connection"
sys.exit(1)
while 1:
table = raw_input("Table name: ")
sql = "select count(*) from %s" % table
cur1 = cn1.cursor()
cur1.execute(sql)
cur2 = cn2.cursor()
cur2.execute(sql)
r1 = cur1.fetchone()
r2 = cur2.fetchone()
if r1[0] == r2[0] == 0:
print "SAME!"
continue
if r1[0] == r2[0]:
print "Same COUNT! "
else:
print "DIFF Found! "
inp = raw_input("specific sql? ")
if inp.strip() == '':
sql = "select * from %s" % table
else:
sql = inp
print "SQL used: %s; " % sql
cur1.execute(sql)
cur2.execute(sql)
try:
while 1:
r1 = cur1.fetchone()
r2 = cur2.fetchone()
if r1 is None and r2 is None:
break
if r1.__str__() != r2.__str__():
print "* ", r1, "\n", "# ", r2
except:
pass
print "Repeat- SQL Used:\n%s;" % sql
if __name__ == '__main__':
main()