# Copyright (c) 2020, XhiveFramework Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE

import xhiveframework


def execute():
	xhiveframework.reload_doc("core", "doctype", "DocField")

	if xhiveframework.db.has_column("DocField", "show_days"):
		xhiveframework.db.sql(
			"""
			UPDATE
				tabDocField
			SET
				hide_days = 1 WHERE show_days = 0
		"""
		)
		xhiveframework.db.sql_ddl("alter table tabDocField drop column show_days")

	if xhiveframework.db.has_column("DocField", "show_seconds"):
		xhiveframework.db.sql(
			"""
			UPDATE
				tabDocField
			SET
				hide_seconds = 1 WHERE show_seconds = 0
		"""
		)
		xhiveframework.db.sql_ddl("alter table tabDocField drop column show_seconds")

	xhiveframework.clear_cache(doctype="DocField")
