2012-04-06 12:24:17 +00:00
|
|
|
import webnotes
|
|
|
|
sql = webnotes.conn.sql
|
|
|
|
from webnotes.model import delete_doc
|
2012-03-22 09:37:28 +00:00
|
|
|
|
2012-04-06 12:24:17 +00:00
|
|
|
def execute():
|
2012-03-22 09:37:28 +00:00
|
|
|
del_rec = {
|
2012-04-06 12:24:17 +00:00
|
|
|
'DocType' : ['Update Series', 'File', 'File Browser Control', 'File Group',
|
|
|
|
'Tag Detail', 'DocType Property Setter', 'Company Group', 'Widget Control',
|
|
|
|
'Update Delivery Date Detail', 'Update Delivery Date',
|
|
|
|
'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag',
|
|
|
|
'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail',
|
|
|
|
'Personalize', 'Patch Util', 'Page Template', 'Module Def Role',
|
|
|
|
'Module Def Item', 'File Group', 'File Browser Control', 'File',
|
|
|
|
'Educational Qualifications', 'Earn Deduction Detail',
|
|
|
|
'DocType Property Setter', 'Contact Detail', 'BOM Report Detail',
|
|
|
|
'BOM Replace Utility Detail', 'BOM Replace Utility',
|
|
|
|
'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied',
|
|
|
|
'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment',
|
|
|
|
'Terms and Conditions', 'Time Sheet', 'Time Sheet Detail', 'Naming Series Options'],
|
|
|
|
'Page' : ['File Browser'],
|
|
|
|
'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan']
|
2012-03-22 09:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for d in del_rec:
|
|
|
|
for r in del_rec[d]:
|
2012-04-06 12:24:17 +00:00
|
|
|
if d=='DocType':
|
|
|
|
sql("delete from tabFeed where doc_type=%s", r)
|
2012-03-22 09:37:28 +00:00
|
|
|
delete_doc(d, r)
|
|
|
|
|
2012-03-30 06:59:06 +00:00
|
|
|
sql("delete from tabDocField where label='Repair Purchase Request' and parent = 'Purchase Request'")
|
2012-04-06 12:24:17 +00:00
|
|
|
|
|
|
|
drop_tables()
|
|
|
|
|
|
|
|
|
|
|
|
def drop_tables():
|
|
|
|
webnotes.conn.commit()
|
|
|
|
from webnotes.model.db_schema import remove_all_foreign_keys
|
|
|
|
remove_all_foreign_keys()
|
|
|
|
count = 0
|
|
|
|
tab_list = sql("SHOW TABLES")
|
|
|
|
for tab in tab_list:
|
|
|
|
if tab[0].startswith('_') or tab[0] in ('tabSingles', 'tabSessions', 'tabSeries'): continue
|
|
|
|
res = sql("SELECT COUNT(*) FROM `tabDocType` WHERE name = %s", tab[0][3:])
|
|
|
|
if not res[0][0]:
|
|
|
|
count += 1
|
|
|
|
print tab[0]
|
|
|
|
sql("DROP TABLE `%s`" % tab[0])
|
|
|
|
print count
|
|
|
|
webnotes.conn.begin()
|