[patch] [cleanup] drop unused tables
diff --git a/patches/june_2013/p05_remove_unused_doctypes.py b/patches/june_2013/p05_remove_unused_doctypes.py
new file mode 100644
index 0000000..62cf880
--- /dev/null
+++ b/patches/june_2013/p05_remove_unused_doctypes.py
@@ -0,0 +1,87 @@
+import webnotes
+
+def execute():
+	doctypes = [
+	"Announcement",
+	"Authorization Rules",
+	"Blog Subscriber",
+	"Books",
+	"Call Log",
+	"Call Log Details",
+	"Campaign Expense",
+	"Communication Log",
+	"Compaint Note",
+	"Company Control",
+	"Competitor",
+	"Complaint Detail",
+	"Desktop Item",
+	"DocType Label",
+	"Employee Training",
+	"Featured Item",
+	"GL Control",
+	"GL Mapper",
+	"GL Mapper Detail",
+	"Holiday Block List",
+	"Holiday Block List Allow",
+	"Holiday Block List Date",
+	"Home Control",
+	"Home Settings",
+	"Item Parameter",
+	"Item Parameter Value",
+	"Lead Email CC Detail",
+	"Manage Account",
+	"Market Segment",
+	"Multi Ledger Report Detail",
+	"Naming Series Options",
+	"Navigation Control",
+	"Online Contact",
+	"Order Reconciliation",
+	"Order Reconciliation Detail",
+	"Other Income Detail",
+	"Partner Target Detail",
+	"Permission Control",
+	"Permission Rules",
+	"Print Style",
+	"Product Catalogue Control",
+	"Product Group",
+	"Product Settings",
+	"Products Settings",
+	"Profile Control",
+	"Project Activity",
+	"Project Activity Update",
+	"Project Control",
+	"Project Cost Breakup",
+	"Related Page",
+	"RV Detail",
+	"Sales Browser Control",
+	"Sandbox",
+	"Search Criteria",
+	"Series Detail",
+	"Shipping Address",
+	"SMS Receiver",
+	"State",
+	"TC Detail",
+	"Territory Target Detail",
+	"Timesheet",
+	"Timesheet Detail",
+	"Top Bar Settings",
+	"Training Session",
+	"Training Session Details",
+	"Transfer Ownership",
+	"Trash Control",
+	"Trend Analyzer Control",
+	"Update Delivery Date",
+	"User Setting-Profile",
+	"User Setting-Role Permission",
+	"User Setting-Role User",
+	"User Settings",
+	"Valuation Control",
+	"Website Product Category",
+	"Workflow Action Detail",
+	"Workflow Engine",
+	"Workflow Rule",
+	"Workflow Rule Detail"
+	]
+	
+	for d in doctypes:
+		webnotes.delete_doc("DocType", d)
\ No newline at end of file
diff --git a/patches/june_2013/p06_drop_unused_tables.py b/patches/june_2013/p06_drop_unused_tables.py
new file mode 100644
index 0000000..baad451
--- /dev/null
+++ b/patches/june_2013/p06_drop_unused_tables.py
@@ -0,0 +1,78 @@
+import webnotes
+
+def execute():
+	tables = [
+	"About Us Team",
+	"Account Balance",
+	"Announcement",
+	"Answer",
+	"Blog Subscriber",
+	"Books",
+	"Call Log",
+	"Call Log Details",
+	"Campaign Expense",
+	"Communication Log",
+	"Compaint Note",
+	"Competitor",
+	"Complaint Detail",
+	"Desktop Item",
+	"DocType Label",
+	"Employee Training",
+	"Featured Item",
+	"GL Mapper",
+	"GL Mapper Detail",
+	"Holiday Block List",
+	"Holiday Block List Allow",
+	"Holiday Block List Date",
+	"Item Parameter",
+	"Item Parameter Value",
+	"Landed Cost Master",
+	"Landed Cost Master Detail",
+	"Lead Email CC Detail",
+	"Lease Agreement",
+	"Lease Installment",
+	"Market Segment",
+	"Multi Ledger Report Detail",
+	"Naming Series Options",
+	"Online Contact",
+	"Order Reconciliation Detail",
+	"Other Income Detail",
+	"Partner Target Detail",
+	"Period",
+	"Print Style",
+	"Product",
+	"Product Group",
+	"Project Activity",
+	"Project Activity Update",
+	"Project Cost Breakup",
+	"Question",
+	"RV Detail",
+	"Related Page",
+	"SMS Receiver",
+	"Sales and Purchase Return Item",
+	"Sandbox",
+	"Series Detail",
+	"Service Order Detail",
+	"Service Quotation Detail",
+	"Shipping Address",
+	"State",
+	"TC Detail",
+	"Territory Target Detail",
+	"Timesheet",
+	"Timesheet Detail",
+	"Training Session",
+	"Training Session Details",
+	"User Setting-Profile",
+	"User Setting-Role Permission",
+	"User Setting-Role User",
+	"Website Product Category",
+	"Workflow Action Detail",
+	"Workflow Rule",
+	"Workflow Rule Detail",
+	]
+	
+	webnotes.conn.sql("commit")
+	all_tables = webnotes.conn.sql_list("show tables")
+	for t in tables:
+		if ("tab" + t) in all_tables:
+			webnotes.conn.sql("drop table `tab%s`" % t)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 03f7e73..a1012ba 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -242,5 +242,6 @@
 	"patches.june_2013.p02_update_project_completed",
 	"execute:webnotes.delete_doc('DocType', 'System Console')",
 	"patches.june_2013.p04_fix_event_for_lead_oppty_project",
-	"patches.june_2013.p05_remove_unused_doctypes"
+	"patches.june_2013.p05_remove_unused_doctypes",
+	"patches.june_2013.p06_drop_unused_tables"
 ]
\ No newline at end of file
diff --git a/startup/startup.py b/startup/startup.py
index 89c0336..2ca2643 100644
--- a/startup/startup.py
+++ b/startup/startup.py
@@ -62,11 +62,6 @@
 def get_open_leads():
 	return webnotes.conn.sql("""select count(*) from tabLead 
 		where status='Open'""")[0][0]
-
-def get_unanswered_questions():
-	return len(filter(lambda d: d[0]==0,
-		webnotes.conn.sql("""select (select count(*) from tabAnswer 
-		where tabAnswer.question = tabQuestion.name) as answers from tabQuestion""")))
 	
 @webnotes.whitelist()
 def get_global_status_messages(arg=None):
@@ -76,6 +71,5 @@
 		'things_todo': get_things_todo(),
 		'todays_events': get_todays_events(),
 		'open_tasks': get_open_tasks(),
-		'unanswered_questions': get_unanswered_questions(),
 		'open_leads': get_open_leads()
 	}