# Copyright (c) 2020, JINGROW and Contributors
# License: MIT. See LICENSE

import jingrow


def execute():
	jingrow.reload_pg("core", "pagetype", "PageField")

	if jingrow.db.has_column("PageField", "show_days"):
		jingrow.db.sql(
			"""
			UPDATE
				tabPageField
			SET
				hide_days = 1 WHERE show_days = 0
		"""
		)
		jingrow.db.sql_ddl("alter table tabPageField drop column show_days")

	if jingrow.db.has_column("PageField", "show_seconds"):
		jingrow.db.sql(
			"""
			UPDATE
				tabPageField
			SET
				hide_seconds = 1 WHERE show_seconds = 0
		"""
		)
		jingrow.db.sql_ddl("alter table tabPageField drop column show_seconds")

	jingrow.clear_cache(pagetype="PageField")
