/frappe-apps-manager:frappe-db-resetfrom frappe-apps-manager
Resets a Frappe development database with backup, reinstall, and fixture installation. Also supports data-only and selective reset modes.
Ships in frappe-apps-manager. Installing the plugin adds it to Claude Code.
Reset and reinitialize Frappe database for development purposes with automatic backup and fresh data setup.
CRITICAL WARNINGS:
Ask user to confirm:
Require explicit confirmation: "Type 'RESET' to confirm"
Create Safety Backup:
bench --site [site-name] backup --with-files
Store backup location for user:
Backup created at:
- Database: sites/[site-name]/private/backups/[timestamp]-database.sql.gz
- Files: sites/[site-name]/private/backups/[timestamp]-files.tar
Offer reset approaches:
A. Full Reinstall (Recommended)
B. Data Reset Only
C. Selective Reset
Full Site Reinstall:
# Reinstall site (drops DB and recreates)
bench --site [site-name] reinstall
# Or with options
bench --site [site-name] reinstall \
--admin-password [password] \
--mariadb-root-password [root-password] \
--install-app erpnext \
--verbose
This will:
Remove User Data:
# Via console
bench --site [site-name] console
# Get all DocTypes
exclude_core = ['User', 'Role', 'DocType', 'Module Def']
for doctype in frappe.get_all('DocType', pluck='name'):
if doctype not in exclude_core:
frappe.db.delete(doctype)
frappe.db.commit()
After reset, offer to install fixtures:
A. Core Fixtures:
bench --site [site-name] install-app [app-name]
B. Custom Fixtures:
# Import fixtures from app
bench --site [site-name] console
>>> from frappe.core.page.data_import_tool import data_import_tool
>>> data_import_tool.import_doc('path/to/fixtures.json')
C. Demo Data:
# Install with demo data
bench --site [site-name] reinstall --install-app erpnext --with-demo-data
A. Create Test Users:
# Via console
users = [
{'email': '[email protected]', 'first_name': 'Sales', 'roles': ['Sales User']},
{'email': '[email protected]', 'first_name': 'Stock', 'roles': ['Stock User']}
]
for user_data in users:
if not frappe.db.exists('User', user_data['email']):
user = frappe.get_doc({
'doctype': 'User',
'email': user_data['email'],
'first_name': user_data['first_name'],
'send_welcome_email': 0
})
user.insert(ignore_permissions=True)
user.add_roles(*user_data['roles'])
frappe.db.commit()
B. Configure Site Settings:
bench --site [site-name] set-config developer_mode 1
bench --site [site-name] set-config allow_tests 1
C. Run Migrations:
bench --site [site-name] migrate
D. Clear Cache:
bench --site [site-name] clear-cache
Check that reset was successful:
Database Check:
# Count records
frappe.db.count('Customer') # Should be 0 or fixture count
frappe.db.count('User') # Should have Administrator + test users
App Installation:
bench --site [site-name] list-apps
Site Access:
bench --site [site-name] browse
# Or manually visit: http://localhost:8000
Login Test:
If reset went wrong, restore from backup:
Restore Database:
bench --site [site-name] --force restore \
sites/[site-name]/private/backups/[backup-file].sql.gz
Restore Files:
cd sites/[site-name]
tar -xzf private/backups/[backup-file]-files.tar
Full Restore:
bench --site [site-name] restore \
--with-public-files sites/[site-name]/private/backups/[timestamp]-database.sql.gz \
--with-private-files sites/[site-name]/private/backups/[timestamp]-files.tar
Frappe Install Module:
Bench Install Commands:
Real Reset Patterns:
# See: erpnext/setup/install.py
def install_fixtures():
from frappe.core.doctype.data_import.data_import import import_doc
for fixture in ['country', 'currency', 'mode_of_payment']:
import_doc(f'erpnext/setup/fixtures/{fixture}.json')
frappe.db.commit()
# See: frappe/installer.py
def after_install():
add_standard_roles()
install_basic_docs()
setup_wizard_complete()
frappe.db.commit()
Reset Specific DocTypes:
# Via console
doctypes_to_reset = ['Sales Invoice', 'Purchase Order', 'Stock Entry']
for doctype in doctypes_to_reset:
# Delete all records
frappe.db.delete(doctype)
# Reset naming series
frappe.db.sql(f"""
UPDATE `tabSeries`
SET current = 0
WHERE name LIKE '{doctype[:4]}%'
""")
frappe.db.commit()
print("Reset complete")
Reset Transactions, Keep Masters:
# Define master DocTypes to keep
master_doctypes = ['Customer', 'Item', 'Supplier', 'Company']
# Get all DocTypes
all_doctypes = frappe.get_all('DocType',
filters={'istable': 0, 'issingle': 0},
pluck='name'
)
# Reset transaction DocTypes
for doctype in all_doctypes:
if doctype not in master_doctypes:
count = frappe.db.count(doctype)
if count > 0:
frappe.db.delete(doctype)
print(f"Deleted {count} {doctype} records")
frappe.db.commit()
Clean Orphaned Records:
# Find and remove orphaned child table records
# Run after selective reset
frappe.db.sql("""
DELETE FROM `tabSales Invoice Item`
WHERE parent NOT IN (SELECT name FROM `tabSales Invoice`)
""")
frappe.db.commit()
Before executing reset, verify:
After reset, verify:
For testing, consider cloning:
# Create copy of site for testing
bench --site original.local backup
bench restore new-test.local \
--source sites/original.local/private/backups/[backup].sql.gz
# Now reset the clone, not original
bench --site new-test.local reinstall
This preserves original site while providing clean environment.
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
15 commands in this plugin
/frappe-backupFrappe Backup CommandBackup Frappe site data and files/frappe-bench-startFrappe Bench Start CommandStart Frappe bench with proper configuration/frappe-cacheFrappe Cache CommandManage Redis cache - clear, monitor, and optimize Frappe cache performance/frappe-configFrappe Config CommandConfigure Frappe site settings - manage site_config.json and environment variables/frappe-consoleFrappe Console CommandLaunch interactive Frappe Python console for debugging and data queries/frappe-deployFrappe Deploy CommandDeploy Frappe apps to production environmentnpx claudepluginhub vyogotech/frappe-apps-manager --plugin frappe-apps-manager2 plugins ship this exact command · first indexed Dec 31, 2025
Other plugins' commands for the same job