bench --site hilltop install-app hilltop

Installing hilltop…
An error occurred while installing hilltop: (‘Module Def’, ‘Hilltop’, IntegrityError(1062, “Duplicate entry ‘Hilltop’ for key ‘PRIMARY’”))
Traceback with variables (most recent call last):
File “apps/frappe/frappe/commands/site.py”, line 462, in install_app
_install_app(app, verbose=context.verbose, force=force)
context = {‘sites’: [‘hilltop’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
apps = (‘hilltop’,)
force = False
_install_app = <function install_app at 0x7fb5e0272d40>
filelock = <function filelock at 0x7fb5e0270e00>
exit_code = 0
site = ‘hilltop’
app = ‘hilltop’
err = DuplicateEntryError(‘Module Def’, ‘Hilltop’, IntegrityError(1062, “Duplicate entry ‘Hilltop’ for key ‘PRIMARY’”))
File “apps/frappe/frappe/installer.py”, line 299, in install_app
add_module_defs(name, ignore_if_duplicate=force)
name = ‘hilltop’
verbose = False
set_as_patched = True
force = False
sync_jobs = <function sync_jobs at 0x7fb5df2e6e80>
sync_for = <function sync_for at 0x7fb5df2e7c40>
sync_customizations = <function sync_customizations at 0x7fb5e03ad440>
sync_fixtures = <function sync_fixtures at 0x7fb5df2e7f60>
app_hooks = {‘app_description’: [‘Hilltop Custom APP’], ‘app_email’: [‘obaid@easycloud.in’], ‘app_license’: [‘mit’], ‘app_name’: [‘hilltop’], ‘app_publisher’: [‘Obaid Masoom’], ‘app_title’: [‘Hilltop’]}
installed_apps = [‘frappe’, ‘erpnext’, ‘hilltop_app’, ‘new_hilltop’, ‘pdf_on_submit’, ‘custom_app’, ‘frappe_whatsapp’, ‘hrms’, ‘payments’, ‘hilltop_custom’]
File “apps/frappe/frappe/installer.py”, line 638, in add_module_defs
d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
app = ‘hilltop’
ignore_if_duplicate = False
modules = [‘Hilltop’]
module = ‘Hilltop’
d = <ModuleDef: Hilltop>
File “apps/frappe/frappe/model/document.py”, line 297, in insert
self = <ModuleDef: Hilltop>
ignore_permissions = True
ignore_links = None
ignore_if_duplicate = False
ignore_mandatory = None
set_name = None
set_child_names = True
File “apps/frappe/frappe/model/base_document.py”, line 577, in db_insert
raise frappe.DuplicateEntryError(self.doctype, self.name, e)
self = <ModuleDef: Hilltop>
ignore_if_duplicate = False
conflict_handler = ‘’
d = {‘name’: ‘Hilltop’, ‘creation’: ‘2024-01-29 14:07:46.332786’, ‘modified’: ‘2024-01-29 14:07:46.332786’, ‘modified_by’: ‘Administrator’, ‘owner’: ‘Administrator’, ‘docstatus’: 0, ‘idx’: 0, ‘module_name’: ‘Hilltop’, ‘custom’: 0, ‘package’: None, ‘app_name’: ‘hilltop’, ‘restrict_to_domain’: None, ‘_user_tags’: None, ‘_comments’: None, ‘_assign’: None, ‘_liked_by’: None}
columns = [‘name’, ‘creation’, ‘modified’, ‘modified_by’, ‘owner’, ‘docstatus’, ‘idx’, ‘module_name’, ‘custom’, ‘package’, ‘app_name’, ‘restrict_to_domain’, ‘_user_tags’, ‘_comments’, ‘_assign’, ‘_liked_by’]
frappe.exceptions.DuplicateEntryError: (‘Module Def’, ‘Hilltop’, IntegrityError(1062, “Duplicate entry ‘Hilltop’ for key ‘PRIMARY’”))

Can you please help me to resolve this error

Hi @JayaLakshmiJilakara,

I believe the hilltop application is causing a duplicate entry issue. To fix this, uninstall the hilltop app and then reinstall it. If the problem persists, you can resolve it by removing or deleting the Hilltop module through the bench console.

Thank You!

Hello @NCP Sir,

When I tried to Unistall the hilltop app, I got this error sir.
jaya@jaya-Lenovo-V15-G3-IAP:~/frappe-bench$ bench --site hilltop uninstall-app hilltop
App hilltop not installed on Site hilltop

Thank You!

Deleting the Hilltop module and Hilltop module related all doctype through the bench console.

import frappe
…: def delete_module_and_doctypes(module_name):
…: try:
…: # Delete all DocTypes associated with the module
…: doctypes = frappe.get_all(‘DocType’, filters={‘module’: module_name})
…: for doctype in doctypes:
…: frappe.delete_doc(‘DocType’, doctype.name, force=True)
…: # Delete the Module Def
…: frappe.delete_doc(‘Module Def’, module_name, force=True)
…: print(f"Module ‘{module_name}’ and associated DocTypes deleted successfully.“)
…: except Exception as e:
…: print(f"Error: {e}”)
…: # Replace ‘Hilltop’ with the actual module name you want to delete
…: delete_module_and_doctypes(‘Hilltop’)
Module ‘Hilltop’ and associated DocTypes deleted successfully.

I delete the related doctypes of hilltop and I run the install-app command and again I got the DuplicateEntryError.

when you uninstall the app then first migrate the site and again install the app.

Please check the post.

Thank You!

Now, It’s working fine.

Thank You Sir !