From 8551cfa32e29a7d5f02ccb7918a37645504677dc Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 20 Sep 2021 21:40:49 +0530 Subject: [PATCH] fix: check if present before adding --- .../patches/v0_0/rename_chapters_and_lessons_doctype.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/community/patches/v0_0/rename_chapters_and_lessons_doctype.py b/community/patches/v0_0/rename_chapters_and_lessons_doctype.py index 0086a14f..82d45556 100644 --- a/community/patches/v0_0/rename_chapters_and_lessons_doctype.py +++ b/community/patches/v0_0/rename_chapters_and_lessons_doctype.py @@ -7,8 +7,11 @@ def execute(): frappe.reload_doc("lms", "doctype", "chapter_reference") frappe.reload_doc("lms", "doctype", "lesson_reference") - move_chapters() - move_lessons() + if not frappe.db.count("Chapter Reference"): + move_chapters() + + if not frappe.db.count("Lesson Reference"): + move_lessons() def move_chapters(): docs = frappe.get_all("Chapters", fields=["*"])