Error while making bench migrate

Hello guys.
Previously I used ERPNext from VM image provided by team. I made a backup of database in VM and now trying to restore it to ubuntu setup(installed by easy install script).

**`bench --site site1.local --force restore ~/database.sql`** command ends successfully without any error. After running **`bench migrate`** it gives my this error:
~/frappe-bench$ bench migrate
Migrating erpn
Updating frappe                     : [=                                       ]Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/haci/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/haci/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/haci/frappe-bench/apps/frappe/frappe/commands.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/haci/frappe-bench/apps/frappe/frappe/commands.py", line 205, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/haci/frappe-bench/apps/frappe/frappe/migrate.py", line 29, in migrate
    frappe.model.sync.sync_all(verbose=verbose)
  File "/home/haci/frappe-bench/apps/frappe/frappe/model/sync.py", line 19, in sync_all
    sync_for(app, force, verbose=verbose)
  File "/home/haci/frappe-bench/apps/frappe/frappe/model/sync.py", line 43, in sync_for
    import_file_by_path(doc_path, force=force)
  File "/home/haci/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 54, in import_file_by_path
    import_doc(doc, force=force, data_import=data_import, pre_process=pre_process)
  File "/home/haci/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 122, in import_doc
    doc.insert()
  File "/home/haci/frappe-bench/apps/frappe/frappe/model/document.py", line 203, in insert
    self.db_insert()
  File "/home/haci/frappe-bench/apps/frappe/frappe/model/base_document.py", line 282, in db_insert
    ), d.values())
  File "/home/haci/frappe-bench/apps/frappe/frappe/database.py", line 136, in sql
    self._cursor.execute(query, values)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/haci/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1048, "Column 'track_seen' cannot be null")

I could find ‘track_seen’ entry only in tabDocType table and non of fields are null, they are either 0 or 1.
Can you please help me. Thank you.

Looks like you have restored a database which was patched using a develop branch, into a bench with all apps in master branch.

You will need to either change your app branches to develop, or create a new bench with develop branch apps and move the site to that new bench.

1 Like

Thank you @anand, it was exactly as you wrote. In VM downloaded from your site bench and ERPNext were in master branch, but frappe was on develop. On ubuntu setup all were in master. I didn’t chage branch in VM, just made few times bench update. So is default combination is master master devolop for bench ERPNext and frappe? And what combo should I use for everyday stable setup?

1 Like

Use master branch for all repos

@valmik can you look into the VM?

1 Like

Could you please explain how should I patch or convert database to be able to use it in master branch?
In VM I tried bench switch-to-master and bench update --patch, it gives me the same error as above.
Thank you for your effort.

Hey @Hadzhi,

Sorry for the trouble, the VM is supposed to be on the master branch, however, something went awry and the Frappe branch turned out to be on develop. I’ve fixed that issue. However, because of the database differences of master and develop, you’re facing this issue.

Now, this is how you can fix it, I’m assuming both your frappe and erpnext are in the master branch :

  1. Take a backup
  2. First do a bench update. It will break and give an error, that’s fine.
  3. Run bench mysql. You should get in the MySQL shell
  4. Run ALTER TABLE tabDocType DROP COLUMN track_seen;
  5. And then run ALTER TABLE tabDocType DROP COLUMN quick_entry;
  6. Exit the SQL terminal, and run bench update
  7. Access your ERPNext to check if everything is working fine
  8. Take new backup and use that for new setup
4 Likes

Thank you @vjFaLk, now all works fine on master branch without any issue.
I am very glad that this team has professional developers like you guys. Keep up this awesome project.

Glad to be of help! :smiley:

Let us know if you have any other issues

1 Like

@vjFaLk.I am also have same issue…

ikhlas@ikhlas:~$ cd frappe-bench
ikhlas@ikhlas:~/frappe-bench$ bench update
remote: Counting objects: 638, done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 638 (delta 507), reused 483 (delta 481), pack-reused 85
Receiving objects: 100% (638/638), 242.11 KiB | 26 KiB/s, done.
Resolving deltas: 100% (513/513), completed with 161 local objects.
From https://github.com/frappe/frappe
   70a4e33..cdddec0  master     -> upstream/master
   9c7d1f2..f025f15  develop    -> upstream/develop
   cc11832..984ec6c  gh-pages   -> upstream/gh-pages
   f85f2f5..cdddec0  hotfix     -> upstream/hotfix
 * [new tag]         v6.27.13   -> v6.27.13
From https://github.com/frappe/frappe
 * [new tag]         v6.27.11   -> v6.27.11
 * [new tag]         v6.27.12   -> v6.27.12
INFO:bench.utils:updating bench
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/frappe/bench
   4d90001..ccea825  develop    -> origin/develop
Already up-to-date.
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Updating 70a4e33..cdddec0
Fast-forward
 frappe/__init__.py                                 |    5 +-
 frappe/__version__.py                              |    2 +-
 frappe/change_log/v6/v6_27_11.md                   |    2 +
 .../core/doctype/communication/communication.json  | 1964 ++++++++++----------
 frappe/core/doctype/communication/communication.py |   42 +-
 frappe/core/doctype/communication/email.py         |   31 +-
 frappe/core/doctype/role/role.json                 |   35 +-
 frappe/core/doctype/role/role.py                   |    8 +
 frappe/core/doctype/role/test_records.json         |    4 +
 frappe/core/doctype/role/test_role.py              |   24 +-
 frappe/core/doctype/user/user.py                   |   15 +-
 frappe/docs/_config.yml                            |    2 -
 frappe/docs/user/en/tutorial/index.md              |    3 -
 frappe/email/bulk.py                               |   31 +-
 frappe/email/doctype/bulk_email/bulk_email.json    |   30 +-
 frappe/email/email_body.py                         |   46 +-
 frappe/email/smtp.py                               |   60 +-
 frappe/hooks.py                                    |    2 +-
 frappe/public/js/frappe/form/footer/timeline.js    |   70 +
 .../js/frappe/form/footer/timeline_item.html       |    2 +
 frappe/public/js/frappe/model/model.js             |   47 -
 frappe/public/js/frappe/views/formview.js          |    8 +-
 setup.py                                           |    2 +-
 23 files changed, 1325 insertions(+), 1110 deletions(-)
 create mode 100644 frappe/change_log/v6/v6_27_11.md
 delete mode 100644 frappe/docs/_config.yml
INFO:bench.app:pulling erpnext
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (15/15), done.
From https://github.com/frappe/erpnext
 * branch            master     -> FETCH_HEAD
Updating 4058af2..1843359
Fast-forward
 erpnext/__version__.py             |    2 +-
 erpnext/crm/doctype/lead/lead.json |    4 ++--
 erpnext/hooks.py                   |    2 +-
 setup.py                           |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
INFO:bench.app:pulling schools
remote: Counting objects: 30, done.
remote: Compressing objects: 100% (18/18), done.
Unpacking objects: 100% (30/30), done.
remote: Total 30 (delta 18), reused 9 (delta 9), pack-reused 3
From https://github.com/frappe/schools
 * branch            develop    -> FETCH_HEAD
Updating b4d67b8..a867820
Fast-forward
 .travis.yml             |    6 +++---
 schools/setup_wizard.py |   26 ++++++++++++++++++--------
 2 files changed, 21 insertions(+), 11 deletions(-)
INFO:bench.app:pulling s3_backup
From https://github.com/ccfiel/s3_backup
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.app:pulling mandrill_integration
From https://github.com/frappe/mandrill_integration
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.app:pulling paypal_integration
From https://github.com/frappe/paypal_integration
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.app:pulling erpnext_shopify
From https://github.com/frappe/erpnext_shopify
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.app:pulling civil_contracting
From https://github.com/revant/civil_contracting
 * branch            master     -> FETCH_HEAD
Already up-to-date.
/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
Migrating civil
Updating frappe                     : [========================================]
Updating civil_contracting          : [========================================]
Migrating erp
Updating frappe                     : [========================================]
Migrating sunerp
Executing frappe.patches.v5_0.style_settings_to_website_theme in sunerp (8f16163e62)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/commands.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/commands.py", line 205, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/migrate.py", line 27, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/patches/v5_0/style_settings_to_website_theme.py", line 10, in execute
    migrate_style_settings()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/patches/v5_0/style_settings_to_website_theme.py", line 28, in migrate_style_settings
    website_theme.use_theme()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/doctype/website_theme/website_theme.py", line 55, in use_theme
    use_theme(self.name)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/doctype/website_theme/website_theme.py", line 62, in use_theme
    website_settings.save()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 244, in save
    self.run_before_save_methods()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 617, in run_before_save_methods
    self.run_method("validate")
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 579, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 735, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 718, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/model/document.py", line 573, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/doctype/website_settings/website_settings.py", line 17, in validate
    self.validate_home_page()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/doctype/website_settings/website_settings.py", line 22, in validate_home_page
    if self.home_page and not resolve_route(self.home_page):
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/router.py", line 46, in resolve_route
    return get_generator_route(path)
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/router.py", line 57, in get_generator_route
    generator_routes = get_generator_routes()
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/website/router.py", line 84, in get_generator_routes
    {2}""".format(route_column_name, doctype, condition), as_dict=True):
  File "/home/ikhlas/frappe-bench/apps/frappe/frappe/database.py", line 147, in sql
    self._cursor.execute(query)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/ikhlas/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'page_name' in 'field list'")
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==2.0.0', 'console_scripts', 'bench')()
  File "/home/ikhlas/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click-6.4-py2.7.egg/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click-6.4-py2.7.egg/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click-6.4-py2.7.egg/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click-6.4-py2.7.egg/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click-6.4-py2.7.egg/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/ikhlas/bench-repo/bench/commands/update.py", line 60, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/ikhlas/bench-repo/bench/commands/update.py", line 90, in _update
    patch_sites(bench=bench_path)
  File "/home/ikhlas/bench-repo/bench/utils.py", line 131, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/ikhlas/bench-repo/bench/utils.py", line 454, in run_frappe_cmd
    raise CommandFailedError(args)
bench.utils.CommandFailedError: ('--site', 'all', 'migrate')
ikhlas@ikhlas:~/frappe-bench$

While changing branch develop (frappe v7 beta) to master (v6 stable) might encounter following errors:

Solution 1:

Error:

_mysql_exceptions.OperationalError: (1048, "Column 'image_view' cannot be null")

Fix:

$ bench mysql
$ ALTER TABLE tabDocType DROP COLUMN image_view;
$ exit

Error:

_mysql_exceptions.OperationalError: (1048, "Column 'beta' cannot be null")

Fix:

$ bench mysql
$ ALTER TABLE tabDocType DROP COLUMN beta;
$ exit

Solution 2:

Restoring Database backup from frappe-bench/sites/**your-site-name**/private/backup/ directory with sql.gz files from backdate, if you earlier was on master branch / installed ERPNext in Production mode.

frappe@your-server-name:~$ cat frappe-bench/sites/your-site-name/site_config.json      ##to find database name
{
 "auto_update": "off", 
 "db_name": "07ea370613", ##<----- Database name 
 "db_password": "xxxxxxxxxxxxxxxx", 
 "encryption_key": "e7KIEezFgBGMNPFu-xxxxxxxxxxxxxxxxxxxxxxxxxx=", 
 "host_name": "xxxxxx", 
 "nginx_port": xxxx
}
frappe@your-server-name:~$ cp frappe-bench/site/your-site-name/private/backups/database_file_name.sql.gz ~/database_file_name.sql.gz
frappe@your-server-name:~$ gzip -d database_file_name.sql.gz
frappe@your-server-name:~$ pv database_file_name.sql | mysql -u root -p database_name
## OR if pv is not installed on your machine
frappe@your-server-name:~$ mysql -u root -p database_name < database_file_name.sql
## Both mysql commands will overwrite your existing database, use it with care!!! make sure to backup before applying commands!!!

Note:

  • Assuming you are already logged into frappe user / custom username used while installing bench on your system.

vishal@vishal-K53SC:~/frappe-bench$ bench migrate
Migrating test_awfis
Updating frappe : [======================================= ]Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/vishal/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/vishal/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/vishal/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/vishal/frappe-bench/apps/frappe/frappe/commands/site.py”, line 207, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/vishal/frappe-bench/apps/frappe/frappe/migrate.py”, line 29, in migrate
frappe.model.sync.sync_all(verbose=verbose)
File “/home/vishal/frappe-bench/apps/frappe/frappe/model/sync.py”, line 19, in sync_all
sync_for(app, force, verbose=verbose)
File “/home/vishal/frappe-bench/apps/frappe/frappe/model/sync.py”, line 43, in sync_for
import_file_by_path(doc_path, force=force)
File “/home/vishal/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 54, in import_file_by_path
import_doc(doc, force=force, data_import=data_import, pre_process=pre_process)
File “/home/vishal/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 122, in import_doc
doc.insert()
File “/home/vishal/frappe-bench/apps/frappe/frappe/model/document.py”, line 227, in insert
d.db_insert()
File “/home/vishal/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 284, in db_insert
), d.values())
File “/home/vishal/frappe-bench/apps/frappe/frappe/database.py”, line 137, in sql
self._cursor.execute(query, values)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/vishal/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1048, “Column ‘is_custom’ cannot be null”)
vishal@vishal-K53SC:~/frappe-bench$ bench mysql

i got this same error when upgrading v7 to v9
what have i do next ?
/home/frappe/frappe-bench# sudo bench update INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull upstream master
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript

  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling erpnext
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    Updating Python libraries…
    INFO:bench.utils:./env/bin/pip install --upgrade pip
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    INFO:bench.utils:./env/bin/pip install -q -r /home/frappe/.bench/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
    Updating node libraries…
    INFO:bench.utils:npm install
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
    npm WARN frappe@ No description
    Backing up sites…
    Patching sites…
    Migrating site1.local
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘doctype’, force=True) #2017-09-22 in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-03-03 in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2017-03-03 in site1.local (1bd3e0294da19198)
    Success
    Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘module_def’) #2017-09-22 in site1.local (1bd3e0294da19198)
    Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
    main()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 217, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
    frappe.modules.patch_handler.run_all()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
    if not run_single(patchmodule = patch):
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 81, in execute_patch
    exec(patchmodule.split(“execute:”)[1],globals())
    File “”, line 1, in
    File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 691, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 146, in reload_doc
    return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 19, in import_files
    reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 24, in import_file
    ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 58, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 131, in import_doc
    doc.insert()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 237, in insert
    d.db_insert()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 299, in db_insert
    ), list(d.values()))
    File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 152, in sql
    self._cursor.execute(query, values)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
    self.errorhandler(self, exc, value)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
    raise errorclass, errorvalue
    _mysql_exceptions.OperationalError: (1048, “Column ‘is_custom’ cannot be null”)
    root@ip-172-31-34-78:/home/frappe/frappe-bench# bench --force --site site1.local reload-doc schools doctype student_batch_name
    Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
    main()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 248, in reload_doc
    frappe.reload_doc(module, doctype, docname, force=context.force)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 691, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 146, in reload_doc
    return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 19, in import_files
    reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 24, in import_file
    ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 58, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 131, in import_doc
    doc.insert()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 237, in insert
    d.db_insert()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 299, in db_insert
    ), list(d.values()))
    File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 152, in sql
    self._cursor.execute(query, values)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
    self.errorhandler(self, exc, value)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
    raise errorclass, errorvalue
    _mysql_exceptions.OperationalError: (1048, “Column ‘is_custom’ cannot be null”)

Is this issue resolved ?

check out this

Worked like a charm for me. Although I could not pinpoint the offending column, so I had to use this little morsel of wisdom:

SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('is_custom')
AND TABLE_SCHEMA='YourDatabase';

I then ranch bench update, and it ran OK, but had trouble with this:

INFO:bench.utils:sudo supervisorctl restart frappe:
unix:///var/run/supervisor.sock no such file

Which I solved with this:

sudo service supervisor restart

Followed by this:
bench restart

FYI I was updating from 7.0.25 to v10!
Worked flawlessly!

1 Like

Thanks this helped me to solve the issue

but i got this error when in bench upate

 Document has been modified after you have opened it (2018-01-05 10:54:26.006028, 2018-01-05 10:54:26.407987). Please refresh to get the latest document

please help me to solve this issue