How to restore V6 backup file and update to current

Hi ,

I have a backup file from a V6 instance that I’d like to restore and subsequently update to the current version

Any ideas on how to achieve this would be greatly appreciated

Thanks

Rsstore backup database to current instance then run bench migrate

Hi @jof2jc

Trust you’re doing well. Do you mean I can restore a V6 backup file on a V10 instance directly?

Thanks

Yes…after restore run bench migrate

Ran into the error below after running bench migrate

pymysql.err.InternalError: (1054, u"Unknown column 'submit_on_creation' in 'field list'")

How best to proceed?

Thanks

Any help here please?

Kind regards,

Okay, so I found out one way to get past this is by directly creating a column in the database

ALTER TABLE tabDocType ADD COLUMN submit_on_creation VARCHAR(40)

Is this recommended or is there another (better) way?

Thanks

@noetico recently migrated from v6 to v9. It wasn’t the most straight forward but he did it.

Hi @tundebabzy

Thanks a lot for the response. The approach to overcome this issue is exactly what was done here

@noetico could you please confirm if there were any side effects of directly creating the columns in the database?

Cheers!

Hello @wale I had no side effects doing this. It was the only way as a matter of fact.

Do bench migrate, fix these columns (you’ll find 1 or 2 more), after each fix, run bench migrate.

Hi @noetico

Many thanks for the feedback. Will proceed accordingly

Kind regards,

Hi @noetico

Trust you’re doing great. I tried this approach but it doesn’t seem to have made much difference. The error message is still the same. When I try creating the column again, I get a duplicate error ERROR 1060 (42S21): Duplicate column name 'submit_on_creation'

Any ideas?

Thanks

Hi @wale

Did you getting above error on bench migrate command? Can you share complete traceback of an error?

Hi @rohit_w

Thanks a lot for your response. No, that error was because I tried to manually create the column in the database twice. I wasn’t sure the column was created successfully the first time so I tried it a second time. I created the column in mysql using the command below:

ALTER TABLE tabDocType ADD COLUMN submit_on_creation VARCHAR(40)

The full trace of the error when running the bench migrate command is shown below:

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/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe1-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/frappe1-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/commands/site.py", line 222, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/migrate.py", line 31, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe1-bench/apps/erpnext/erpnext/patches/v6_24/set_recurring_id.py", line 8, in execute
    where is_recurring=1'''.format(doctype))
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/database.py", line 176, in sql
    self._cursor.execute(query)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 165, in execute
    result = self._query(query)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 860, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1061, in _read_query_result
    result.read()
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1349, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1018, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, u"Unknown column 'submit_on_creation' in 'field list'")

This is the error I’ve been trying to resolve. Any suggestions on how to get around this?

Thanks

submit_on_creation was addd in version 6 and removed in version 9. To fix the issue, you have to add this field in sales order, sales invoice, purchase order, purchase invoice

ALTER TABLE `tabSales Order` ADD COLUMN submit_on_creation VARCHAR(40);
ALTER TABLE `tabSales Invoice` ADD COLUMN submit_on_creation VARCHAR(40);
ALTER TABLE `tabPurchase Order` ADD COLUMN submit_on_creation VARCHAR(40);
ALTER TABLE `tabPurchase Invoice` ADD COLUMN submit_on_creation VARCHAR(40);

After that run bench migrate and check

Hi @rohit_w

Thanks a great deal for your help. Your suggestion helped me get past that error and also other errors afterwards but now there’s a different one! :flushed:

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/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe1-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/frappe1-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/commands/site.py", line 222, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/migrate.py", line 31, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe1-bench/apps/erpnext/erpnext/patches/v6_20x/set_compact_print.py", line 7, in execute
    create_compact_item_print_custom_field()
  File "/home/frappe/frappe1-bench/apps/erpnext/erpnext/setup/install.py", line 54, in create_compact_item_print_custom_field
    'insert_after': 'with_letterhead'
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 106, in create_custom_field
    "hidden": df.hidden or 0
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 245, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 887, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 755, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 1024, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 1007, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/model/document.py", line 749, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 51, in on_update
    validate_fields_for_doctype(self.dt)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 389, in validate_fields_for_doctype
    validate_fields(frappe.get_meta(doctype, cached=False))
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 630, in validate_fields
    check_link_table_options(d)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 435, in check_link_table_options
    frappe.throw(_("Options must be a valid DocType for field {0} in row {1}").format(d.label, d.idx))
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/__init__.py", line 323, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
    _raise_exception()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
frappe.exceptions.ValidationError: Options must be a valid DocType for field Print Style in row 16

Any ideas please?

Thanks

run below command

bench --force --site <your-site-name> reload-doc printing doctype print_style

Hi @rohit_w

Thanks yet again for your kind assistance. I however just encountered another error

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/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe1-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe1-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/frappe1-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/commands/site.py", line 222, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/migrate.py", line 31, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe1-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe1-bench/apps/erpnext/erpnext/patches/v7_0/convert_timelog_to_timesheet.py", line 19, in execute
    time_sheet = make_timesheet(data.production_order)
TypeError: make_timesheet() takes exactly 2 arguments (1 given)

How to proceed?

Thanks