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

import influxframework


def execute():
	if not influxframework.db.table_exists("Data Import"):
		return

	meta = influxframework.get_meta("Data Import")
	# if Data Import is the new one, return early
	if meta.fields[1].fieldname == "import_type":
		return

	influxframework.db.sql("DROP TABLE IF EXISTS `tabData Import Legacy`")
	influxframework.rename_doc("DocType", "Data Import", "Data Import Legacy")
	influxframework.db.commit()
	influxframework.db.sql("DROP TABLE IF EXISTS `tabData Import`")
	influxframework.rename_doc("DocType", "Data Import Beta", "Data Import")
