Upgrading ERPNext v11 --> v12, problem with switch-to-branch

Continuing the discussion from Moving to ERPNext v12:

I am trying to upgrade v11 → v12 with these steps

  1. cd ~/frappe-bench
  2. bench update
  3. bench setup requirements
  4. bench switch-to-branch version-12 frappe erpnext --upgrade
  5. bench update --patch
  6. bench migrate
  7. bench update --build

steps 1-3 work fine but with

bench switch-to-branch version-12 ... I am hitting an error

seems the critical moment comes with yarn install

$ yarn install
yarn install v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.3.1" has unmet peer dependency "popper.js@^1.14.7".
[4/4] Building fresh packages...
Done in 96.48s.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/bench/bench/cli.py", line 41, in cli
    bench_command()
  File "/home/frappe/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/bench/bench/commands/update.py", line 43, in switch_to_branch
    switch_to_branch(branch=branch, apps=list(apps), upgrade=upgrade)
  File "/home/frappe/bench/bench/app.py", line 417, in switch_to_branch
    switch_branch(branch, apps=apps, bench_path=bench_path, upgrade=upgrade)
  File "/home/frappe/bench/bench/app.py", line 409, in switch_branch
    reload_module(utils)
NameError: global name 'utils' is not defined

the entire output of bench switch-to-branch version-12 frappe erpnext --upgrade can be found here

got passed the above by throwing in a

git config remote.upstream.fetch “+refs/heads/*:refs/remotes/upstream/*”

in the

  1. .../apps/erpnext and the
  2. .../apps/frappe folder

before running the ...switch-to-branch

now I am getting this error on #5 bench update --patch

git config remote.upstream.fetch “+refs/heads/:refs/remotes/upstream/

Would I need to apply this config change to a third party app as well?

disclaimer> I have no experience with 3rd party apps whatsoever

that being said … I would say if your App has the same branch logic as erpnext/frappe (and likewise there exists a version-12 branch for your app) it may be catched by the bench switch-to-branch version-12 frappe erpnext [custom_app] --upgrade command (beware the [custom_app] in there)

I personally would say ist makes sense to have the same branch structure for a [custom_app] and would even do this if there was no change between the apps branches version-11 and version-12 (just for the sake of having the same structure in all your apps, but that is just a personal taste I guess)

that would not at all solve any compatibility issues (if there where any) between v12 and the [custom_app] of course

1 Like

generally I would just try to understand the structure of the command

bench switch-to-branch version-12 frappe erpnext --upgrade

and draw conclusions from it in regards to your particular scenario.

So switch-to-branch [branch_name] is followed by the apps you want to address (frappe & erpnext being the 2 apps everybody has in a standard ERPNext environment)

Thank you, it solved the well documented test.fm hurdle. Now I’ve reached the xlrd problem, but I’ve fixed that one before.

I’m at this point now with exactly the same outcome, but it’s after the line:
Migrating frapcl
Where as yours is
Migrating erp.w*****mei.com

Another thread has this solution.
‘redis-cli -p 13000 FLUSHALL’

I reran bench update --patch with success.

tried this and then bench update --patch again

got me a bunch of other errors

the one that catches my eye is

frappe.exceptions.DuplicateEntryError: ('UOM Conversion Factor', 'MAT-UOM-CNV-00001', IntegrityError(1062, "Duplicate entry 'MAT-UOM-CNV-00001' for key 'PRIMARY'"))

"Duplicate entry 'MAT-UOM-CNV-00001' for key 'PRIMARY'" is not true. I have looked it up in the initial database and there is only one entry with the PRIMARY KEY ‘MAT-UOM-CNV-00001’ in the tabUOM Conversion Factor

this is the Conversion Meeter:Meeter = 1.
I wonder whether it may help whether I remove or replace that entry (if possible) before going through this.

1 Like

I have not made any progress with this, but filtered a bit what I assume to be the problematic patch to be erpnext.patches.v12_0.update_uom_conversion_factor

Executing erpnext.patches.v12_0.update_uom_conversion_factor in erp.mydomain.com (ced3ffaac376878b)
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 325, in db_insert
    ), list(d.values()))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 156, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry 'MAT-UOM-CNV-00001' for key 'PRIMARY'")

the complaint pymysql.err.IntegrityError: (1062, "Duplicate entry 'MAT-UOM-CNV-00001' for key 'PRIMARY'") makes no sense to me when I look into the database (the original production db).

MariaDB [db_name]> SELECT name FROM `tabUOM Conversion Factor` WHERE name LIKE "%0000%";
+-------------------+
| name              |
+-------------------+
| MAT-UOM-CNV-00001 |
| MAT-UOM-CNV-00007 |
+-------------------+
2 rows in set (0.001 sec)

I believe there is a way to skip certain patches. maybe that would serve me well. Can somebody advise on this?

the actual solution come in this post