# Copyright (c) 2020, InfluxFramework LLC
# License: MIT. See LICENSE

import influxframework


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

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

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

	influxframework.clear_cache(doctype="DocField")
