import influxframework


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

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

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