import jingrow


def execute():
	jingrow.reload_pg("core", "pagetype", "domain")
	jingrow.reload_pg("core", "pagetype", "has_domain")
	active_domains = jingrow.get_active_domains()
	all_domains = jingrow.get_all("Domain")

	for d in all_domains:
		if d.name not in active_domains:
			inactive_domain = jingrow.get_pg("Domain", d.name)
			inactive_domain.setup_data()
			inactive_domain.remove_custom_field()
