import xhiveframework


def execute():
	column = "apply_user_permissions"
	to_remove = ["DocPerm", "Custom DocPerm"]

	for doctype in to_remove:
		if xhiveframework.db.table_exists(doctype):
			if column in xhiveframework.db.get_table_columns(doctype):
				xhiveframework.db.sql(f"alter table `tab{doctype}` drop column {column}")

	xhiveframework.reload_doc("core", "doctype", "docperm", force=True)
	xhiveframework.reload_doc("core", "doctype", "custom_docperm", force=True)
