Error in v4 to v5 Migration

Error in migrating from v4 to v5

Executing frappe.patches.v5_0.style_settings_to_website_theme

frappe.exceptions.NameError: (u’Website Theme’, u’Custom’, IntegrityError(1062, “Duplicate entry ‘Custom’ for key ‘PRIMARY’”))

Migrating castlecraft.in
Executing frappe.patches.v5_0.convert_to_barracuda_and_utf8mb4 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2015-01-01 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('email', 'doctype', 'email_alert') #2014-07-15 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('desk', 'doctype', 'todo') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('custom', 'doctype', 'property_setter') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.v4_to_v5 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.remove_shopping_cart_app in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("Module Def") in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("User") #2015-03-24 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.rename_table_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.communication_parent in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.clear_website_group_and_notifications in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("""update tabComment set comment = substr(comment, 6, locate(":", comment)-6) where comment_type in ("Assigned", "Assignment Completed")""") in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_feed in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.update_shared in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.bookmarks_to_stars in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.style_settings_to_website_theme in castlecraft.in (cpes-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/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 77, in <module>
    main()
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 14, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 202, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/revant/frappe-bench/apps/frappe/frappe/patches/v5_0/style_settings_to_website_theme.py", line 10, in execute
    migrate_style_settings()
  File "/home/revant/frappe-bench/apps/frappe/frappe/patches/v5_0/style_settings_to_website_theme.py", line 27, in migrate_style_settings
    website_theme.save()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/document.py", line 214, in save
    self.insert()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/document.py", line 186, in insert
    self.db_insert()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/base_document.py", line 243, in db_insert
    ), d.values())
  File "/home/revant/frappe-bench/apps/frappe/frappe/database.py", line 129, in sql
    self._cursor.execute(query, values)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
frappe.exceptions.NameError: (u'Website Theme', u'Custom', IntegrityError(1062, "Duplicate entry 'Custom' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/revant/bench-repo/bench/cli.py", line 55, in cli
    bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/revant/bench-repo/bench/utils.py", line 118, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/revant/bench-repo/bench/utils.py", line 427, in run_frappe_cmd
    subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('/home/revant/frappe-bench/env/bin/python', '-m', 'frappe.utils.bench_helper', 'frappe', '--site', 'all', 'migrate')' returned non-zero exit status 1

Hi.

Did you already have a doctype called “Website Theme” before maybe in your custom app?

thanks,
Anand.

There is no custom app, only erpnext, frappe and shopping_cart was there.

Executing frappe.patches.v5_0.remove_shopping_cart_app in castlecraft.in (cpes-frappe)
Success

Its a copy of production just to test migration. so I dropped table “tabWebsite Theme” and tried:

Executing frappe.patches.v5_0.style_settings_to_website_theme in castlecraft.in (cpes-frappe)
Success
. . . 
Executing execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) in castlecraft.in (cpes-frappe)
. . . 
_mysql_exceptions.OperationalError: (1050, "Table 'tabIssue' already exists")

so I dropped table “tabIssue” and tried:

Executing execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v4_4.make_email_accounts in castlecraft.in (cpes-frappe)
. . . .
frappe.exceptions.NameError: ('Email Account', u'Cs', IntegrityError(1062, "Duplicate entry 'Cs' for key 'PRIMARY'"))

so I dropped tabEmail Account: and nothing changed.

Executing erpnext.patches.v4_4.make_email_accounts in castlecraft.in (cpes-frappe)
. . . .
frappe.exceptions.NameError: ('Email Account', u'Cs', IntegrityError(1062, "Duplicate entry 'Cs' for key 'PRIMARY'"))

@revant_one it seems your database was synced before patches were run. Can you restore a v4 backup and do bench upgrade cleanly again?

I only have backups since March 26th 2015, Restored that backup and tried, It is yet not working.
Stuck at same “Website Theme” error mentioned above.

BTW I’ve not used Issue, Support Ticket, Website Theme, So the data in those tables in not important for me. I’m ready to delete those if ERPNext 5 is what I get. :smile:

Email Accounts: I had configured outgoing email on ERPNext 4, I can afford to lose that configuration too for ERPNext 5.

I wish to use migrate! I migrated from 3 to 4 now It’s time for 4 to 5

Last Resort: Stop migrating now & only install stable ERPNext 5. Then use data import for each previously used doctype.

frappe.patches.v5_0.style_settings_to_website_theme
....
frappe.exceptions.NameError: (u'Website Theme', u'Custom', IntegrityError(1062, "Duplicate entry 'Custom' for key 'PRIMARY'"))

I deleted row for custom from ‘tabWebsite Theme’ and it ran successfully

frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) in castlecraft.in (cpes-frappe)
....
_mysql_exceptions.OperationalError: (1050, "Table 'tabIssue' already exists")

I dropped ‘tabIssue’ and it ran successfully.

erpnext.patches.v5_0.rename_table_fieldnames
/home/revant/frappe-bench/apps/frappe/frappe/core/doctype/journal_entry/journal_entry.json missing
/home/revant/frappe-bench/apps/frappe/frappe/core/doctype/monthly_distribution/monthly_distribution.json missing
....
frappe.exceptions.DoesNotExistError: DocType Journal Entry not found

/home/revant/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.json &
/home/revant/frappe-bench/apps/erpnext/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.json exists so i created a link to it in apps/frappe/frappe/core/doctype/ and it ran successfully

erpnext.patches.v4_4.make_email_accounts
....
ImportError: No module named email_reply_parser

./env/bin/pip install email_reply_parser
solved it.

erpnext.patches.v5_0.rename_customer_issue
....
_mysql_exceptions.OperationalError: (1050, "Table 'tabWarranty Claim' already exists")

I dropped ‘tabWarranty Claim’ and it ran successfully

erpnext.patches.v5_0.update_item_description_and_image
....
AttributeError: 'NoneType' object has no attribute 'old_description'

removed line erpnext.patches.v5_0.update_item_description_and_image from erpnext/patches.txt

erpnext.patches.v5_0.newsletter
....
frappe.exceptions.NameError: ('Newsletter List', 'General', IntegrityError(1062, "Duplicate entry 'General' for key 'PRIMARY'"))

I did,
DELETE FROM cpes-frappe.tabNewsletter List WHERE name=‘General’;
and it ran successfully

These patches if removed/hacked the migration is complete.

I tried bench retry-upgrade and now the website shows.
localhost/Desk somehow is shown as json

@revant_one Aribtrarily dropping tables and playing with the schema is a very bad idea

Just restore cleanly and post the issues you face.

  1. Fresh Dump of production
  2. Dropped db on testing machine and restored clean fresh, copy of db from production
  3. bench switch-to-develop, bench update --pull, bench update --patch
  4. first it stopped at executing erpnext.patches.v4_4.make_email_accounts saying ImportError: No module named email_reply_parser
  5. bench update --requirements
  6. bench update --patch
  7. Error Executing erpnext.patches.v5_0.update_item_description_and_image in castlecraft.in (cpes-frappe)
Executing erpnext.patches.v5_0.update_item_description_and_image in castlecraft.in (cpes-frappe)
/home/revant/frappe-bench/apps/erpnext/erpnext/selling/doctype/opportunity_item/opportunity_item.json missing
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/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 77, in <module>
    main()
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 14, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 202, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/revant/frappe-bench/apps/erpnext/erpnext/patches/v5_0/update_item_description_and_image.py", line 29, in execute
    .format("item" if dt=="BOM" else "item_code", dt), as_dict=1)
  File "/home/revant/frappe-bench/apps/frappe/frappe/database.py", line 140, in sql
    self._cursor.execute(query)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/revant/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 'image' in 'where clause'")
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/revant/bench-repo/bench/cli.py", line 55, in cli
    bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/revant/bench-repo/bench/utils.py", line 118, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/revant/bench-repo/bench/utils.py", line 427, in run_frappe_cmd
    subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('/home/revant/frappe-bench/env/bin/python', '-m', 'frappe.utils.bench_helper', 'frappe', '--site', 'all', 'migrate')' returned non-zero exit status 1

This error also occurs while migrating fresh new v4 site to v5.

  1. bench switch-to-v4
  2. create new site
  3. install erpnext and shopping_cart
  4. Go through setup wizard filling mandatory fields
  5. bench switch-to-develop
  6. bench update --requirements
  7. bench update --patch
  8. Error: Executing erpnext.patches.v5_0.update_item_description_and_image in castlecraft.in - same as above

Fresh site migration was solved.
https://github.com/frappe/erpnext/issues/3057

Clean restored database from fresh production database
I’m getting error:

revant@revant-laptop:~/frappe-bench$ bench update --upgrade
Already up-to-date.
From https://github.com/frappe/shopping-cart
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
From https://github.com/frappe/frappe
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
From https://github.com/frappe/erpnext
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
Migrating castlecraft.in
Executing frappe.patches.v5_0.convert_to_barracuda_and_utf8mb4 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2015-01-01 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('email', 'doctype', 'email_alert') #2014-07-15 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('desk', 'doctype', 'todo') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('custom', 'doctype', 'property_setter') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.v4_to_v5 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.remove_shopping_cart_app in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("Module Def") in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("User") #2015-03-24 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.rename_table_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.communication_parent in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.clear_website_group_and_notifications in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("""update tabComment set comment = substr(comment, 6, locate(":", comment)-6) where comment_type in ("Assigned", "Assignment Completed")""") in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_feed in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.update_shared in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.bookmarks_to_stars in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.style_settings_to_website_theme in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.rename_ref_type_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_email_alert in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_null_date_datetime in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.force_sync_website in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("GL Entry") #2014-06-09 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("Stock Ledger Entry") #2014-06-09 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v4_4.make_email_accounts in castlecraft.in (cpes-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/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 77, in <module>
    main()
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 14, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 202, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/revant/frappe-bench/apps/erpnext/erpnext/patches/v4_4/make_email_accounts.py", line 58, in execute
    existing_account.save()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/document.py", line 214, in save
    self.insert()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/document.py", line 186, in insert
    self.db_insert()
  File "/home/revant/frappe-bench/apps/frappe/frappe/model/base_document.py", line 254, in db_insert
    ), d.values())
  File "/home/revant/frappe-bench/apps/frappe/frappe/database.py", line 132, in sql
    self._cursor.execute(query, values)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
frappe.exceptions.NameError: ('Email Account', u'Cs', IntegrityError(1062, "Duplicate entry 'Cs' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/revant/bench-repo/bench/cli.py", line 55, in cli
    bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/revant/bench-repo/bench/utils.py", line 118, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/revant/bench-repo/bench/utils.py", line 427, in run_frappe_cmd
    subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('/home/revant/frappe-bench/env/bin/python', '-m', 'frappe.utils.bench_helper', 'frappe', '--site', 'all', 'migrate')' returned non-zero exit status 1

Delete the email pulling settings and outgoing email settings and migrate again. Will look into this issue (make an issue on github too :slight_smile: )

@pdvyas Deleting all email pulling and outgoing settings worked.

https://github.com/frappe/erpnext/issues/3094

Back to Issue: Migration Error: Executing erpnext.patches.v5_0.update_item_description_and_image

revant@revant-laptop:~/frappe-bench$ bench switch-to-develop
Switched to branch 'develop'
Your branch is up-to-date with 'upstream/develop'.
Switched to branch 'develop'
Your branch is up-to-date with 'upstream/develop'.
Switched to branch 'develop'
Your branch is up-to-date with 'upstream/develop'.

Switched to develop
Please run `bench update --patch` to be safe from any differences in database schema
revant@revant-laptop:~/frappe-bench$ bench update --upgrade
Already up-to-date.
From https://github.com/frappe/shopping-cart
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
From https://github.com/frappe/frappe
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
From https://github.com/frappe/erpnext
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
Migrating castlecraft.in
Executing frappe.patches.v5_0.convert_to_barracuda_and_utf8mb4 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2015-01-01 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('email', 'doctype', 'email_alert') #2014-07-15 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('desk', 'doctype', 'todo') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('custom', 'doctype', 'property_setter') #2014-12-31-1 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.v4_to_v5 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.remove_shopping_cart_app in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("Module Def") in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("User") #2015-03-24 in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.rename_table_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.communication_parent in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.clear_website_group_and_notifications in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("""update tabComment set comment = substr(comment, 6, locate(":", comment)-6) where comment_type in ("Assigned", "Assignment Completed")""") in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_feed in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.update_shared in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.bookmarks_to_stars in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.style_settings_to_website_theme in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.rename_ref_type_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_email_alert in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.fix_null_date_datetime in castlecraft.in (cpes-frappe)
Success
Executing frappe.patches.v5_0.force_sync_website in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("GL Entry") #2014-06-09 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.permissions.reset_perms("Stock Ledger Entry") #2014-06-09 in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True) in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v4_4.make_email_accounts in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v4_2.reset_bom_costs in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_frozen_accounts_permission_role in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_dn_against_doc_fields in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("update `tabMaterial Request` set material_request_type = 'Material Transfer' where material_request_type = 'Transfer'") in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('stock', 'doctype', 'item') in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("update `tabItem` i set apply_warehouse_wise_reorder_level=1, re_order_level=0, re_order_qty=0 where exists(select name from `tabItem Reorder` where parent=i.name)") in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.set_default_company_in_bom in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.capacity_planning in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('crm', 'doctype', 'lead') in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('crm', 'doctype', 'opportunity') in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.rename_table_fieldnames in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''") in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v4_2.party_model in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.party_model_patch_fix in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.recalculate_total_amount_in_jv in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_companywise_payment_account in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.remove_birthday_events in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_item_name_in_bom in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.rename_customer_issue in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.rename_total_fields in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.new_crm_module in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_material_transfer_for_manufacture in castlecraft.in (cpes-frappe)
Success
Executing execute:frappe.reload_doc('crm', 'doctype', 'opportunity_item') in castlecraft.in (cpes-frappe)
Success
Executing erpnext.patches.v5_0.update_item_description_and_image in castlecraft.in (cpes-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/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 77, in <module>
    main()
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 14, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 202, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/revant/frappe-bench/apps/erpnext/erpnext/patches/v5_0/update_item_description_and_image.py", line 33, in execute
    if cstr(d.description) == item_details.get(d.item_code).old_description:
AttributeError: 'NoneType' object has no attribute 'old_description'
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/revant/bench-repo/bench/cli.py", line 55, in cli
    bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/revant/bench-repo/bench/utils.py", line 118, in patch_sites
    run_frappe_cmd('--site', 'all', 'migrate', bench=bench)
  File "/home/revant/bench-repo/bench/utils.py", line 427, in run_frappe_cmd
    subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('/home/revant/frappe-bench/env/bin/python', '-m', 'frappe.utils.bench_helper', 'frappe', '--site', 'all', 'migrate')' returned non-zero exit status 1