Invalid field name: enable_audit_trail

When I migrate site then below error comes.

Queued rebuilding of search index for site1.local

Traceback with variables (most recent call last):
File “/usr/lib/python3.10/runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
mod_name = ‘frappe.utils.bench_helper’
alter_argv = True
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, origin=‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
code = <code object at 0x7f3f11c77b50, file “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
main_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, origin=‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warnings.py’>, ‘click’:…
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
code = <code object at 0x7f3f11c77b50, file “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
run_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, origin=‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warnings.py’>, ‘click’:…
init_globals = None
mod_name = ‘main
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>, origin=‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
pkg_name = ‘frappe.utils’
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f3f12ecb280>
fname = ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’
cached = ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 109, in
main()
…skipped… 25 vars
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=“bench”)
commands = {‘frappe’: , ‘get-frappe-commands’: , ‘get-frappe-help’: }
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
self =

args = ()
kwargs = {‘prog_name’: ‘bench’}
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
self =
args = [‘frappe’, ‘–site’, ‘site1.local’, ‘migrate’]
prog_name = ‘bench’
complete_var = None
standalone_mode = True
extra = {}
ctx = <click.core.Context object at 0x7f3f11c7ae30>
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke…_process_result at 0x7f3f11c93eb0>
args = [‘migrate’]
cmd_name = ‘frappe’
cmd =
sub_ctx = <click.core.Context object at 0x7f3f11c7afe0>
ctx = <click.core.Context object at 0x7f3f11c7ae30>
self =
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke…_process_result at 0x7f3f11ab3520>
args = []
cmd_name = ‘migrate’
cmd =
sub_ctx = <click.core.Context object at 0x7f3f11aab9d0>
ctx = <click.core.Context object at 0x7f3f11c7afe0>
self =
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
self =
ctx = <click.core.Context object at 0x7f3f11aab9d0>
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
self = <click.core.Context object at 0x7f3f11aab9d0>
callback = <function migrate at 0x7f3f11a539a0>
ctx = <click.core.Context object at 0x7f3f11aab9d0>
File “/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
f = <function migrate at 0x7f3f11a53760>
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
ctx = <click.core.Context object at 0x7f3f11aab9d0>
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
profile = False
f = <function migrate at 0x7f3f11a536d0>
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 686, in migrate
SiteMigration(
context = {‘sites’: [‘site1.local’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
skip_failing = False
skip_search_index = False
activate_by_import = <module ‘traceback_with_variables.activate_by_import’ from ‘/home/frappe/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py’>
SiteMigration = <class ‘frappe.migrate.SiteMigration’>
site = ‘site1.local’
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 182, in run
self.post_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7f3f11aabcd0>
site = ‘site1.local’
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 52, in wrapper
raise e
args = (<frappe.migrate.SiteMigration object at 0x7f3f11aabcd0>,)
kwargs = {}
method = <function SiteMigration.post_schema_updates at 0x7f3f0f9b5c60>
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 44, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7f3f11aabcd0>,)
kwargs = {}
method = <function SiteMigration.post_schema_updates at 0x7f3f0f9b5c60>

File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 150, in post_schema_updates
frappe.get_attr(fn)()
self = <frappe.migrate.SiteMigration object at 0x7f3f11aabcd0>
app = ‘india_compliance’
fn = ‘india_compliance.audit_trail.setup.after_migrate’
File “/home/frappe/frappe-bench/apps/india_compliance/india_compliance/audit_trail/setup.py”, line 39, in after_migrate
if is_audit_trail_enabled():
File “/home/frappe/frappe-bench/apps/india_compliance/india_compliance/audit_trail/utils.py”, line 6, in is_audit_trail_enabled
return bool(frappe.db.get_single_value(“Accounts Settings”, “enable_audit_trail”))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 792, in get_single_value
frappe.throw(
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7f3f0f9acbb0>
doctype = ‘Accounts Settings’
fieldname = ‘enable_audit_trail’
cache = True
val = None
df = None
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 540, in throw
msgprint(
msg = ‘Invalid field name: enable_audit_trail
exc = <class ‘frappe.database.database.Database.InvalidColumnName’>
title = None
is_minimizable = False
wide = False
as_list = False
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 508, in msgprint
_raise_exception()
title = None
as_table = False
as_list = False
indicator = ‘red’
alert = False
primary_action = None
is_minimizable = False
wide = False
realtime = False
sys = <module ‘sys’ (built-in)>
out = {‘message’: ‘Invalid field name: enable_audit_trail’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1}
_raise_exception = <function msgprint…_raise_exception at 0x7f3f0ef12c20>
_strip_html_tags = <functools._lru_cache_wrapper object at 0x7f3f0f09afb0>
msg = ‘Invalid field name: enable_audit_trail’
raise_exception = <class ‘frappe.database.database.Database.InvalidColumnName’>
strip_html_tags = <function strip_html_tags at 0x7f3f11c5ac20>
…skipped… 1 vars
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 454, in _raise_exception
raise raise_exception(msg)
msg = ‘Invalid field name: enable_audit_trail’
raise_exception = <class ‘frappe.database.database.Database.InvalidColumnName’>
…skipped… 1 vars
frappe.database.database.InvalidColumnName: Invalid field name: enable_audit_trail

Hi,

Do you have exported customizations of Accounts Settings in any of your custom apps? That may cause newly created, system generated custom fields that have not been exported to get erroneously deleted. This is due to the following open issue:

I have already responded to your GIthub issue with remedial steps:

You just need to run following to recreate the lost enable_audit_trail field:

bench execute india_compliance.audit_trail.setup.setup_fixtures
1 Like

Let me try this.

No, not in custom app also.

Issue solve with run command.