Update/patch from v8 fails on 6 patch modules

I have been working on a system which WAS on frappe/erpnext 8.0.66/8.0.48, and which crashed during an update. Using a bunch of completely not-recommended mangles, I managed to get the system to hobble along.
After several “bench update --reset” fails, I started commenting out the patches which fail to get past as many as possible. (Thanks to clarkej for teaching me about this part - even though I didn’t understand what he was talking about at the time)

sed -i “s/erpnext.patches.v8_0.move_account_head_/ERPNext.patches.v8_0.move_account_head_/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;
sed -i “s/erpnext.patches.v8_0.update_stock_qty_value_in_bom_item/ERPNext.patches.v8_0.update_stock_qty_value_in_bom_item/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;
sed -i “s/erpnext.patches.v8_7.make_subscription_from_recurring_data/ERPNext.patches.v8_7.make_subscription_from_recurring_data/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;
sed -i “s/erpnext.patches.v8_10.change_default_customer_credit_days/ERPNext.patches.v8_10.change_default_customer_credit_days/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;
sed -i “s/erpnext.patches.v9_1.create_issue_opportunity_type/ERPNext.patches.v9_1.create_issue_opportunity_type/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;
sed -i “s/erpnext.patches.v10_0.set_default_payment_terms/ERPNext.patches.v10_0.set_default_payment_terms/” ~/frappe-bench/apps/erpnext/erpnext/patches.txt;

The system is now on
ERPNext: v10.1.48 (master)
Frappe Framework: v10.1.16 (master)
and I have isolated the errors down to the following:

  • Executing erpnext.patches.v8_0.move_account_head_from_account_to_warehouse_for_inventory
    • pymysql.err.InternalError: (1054, u"Unknown column ‘warehouse’ in ‘where clause’")
  • Executing erpnext.patches.v8_0.update_stock_qty_value_in_bom_item
    • pymysql.err.InternalError: (1054, u"Unknown column ‘qty’ in ‘field list’")
  • Executing erpnext.patches.v8_7.make_subscription_from_recurring_data
    • pymysql.err.InternalError: (1054, u"Unknown column ‘end_date’ in ‘field list’")
  • Executing erpnext.patches.v8_10.change_default_customer_credit_days
    • pymysql.err.InternalError: (1054, u"Unknown column ‘credit_days’ in ‘field list’")
  • Executing erpnext.patches.v9_1.create_issue_opportunity_type
    • pymysql.err.InternalError: (1054, u"Unknown column ‘enquiry_type’ in ‘field list’")
  • Executing erpnext.patches.v10_0.set_default_payment_terms_based_on_company
    • pymysql.err.InternalError: (1054, u"Unknown column ‘credit_days’ in ‘field list’")

I don’t know why the frappe hasn’t gone to the latest v10.1.45?

It seems like the DB hasn’t migrated correctly, but when I compare the DDL in a mysql GUI app, they look the same.

bench update gives the following error:
Cannot proceed with update: You have local changes in app “erpnext” that are not committed.
Here are your choices:
1. Merge the erpnext app manually with “git pull” / “git pull --rebase” and fix conflicts.
1. Temporarily remove your changes with “git stash” or discard them completely
_ with “bench update --reset” or for individual repositries “git reset --hard”_
2. If your changes are helpful for others, send in a pull request via GitHub and
_ wait for them to be merged in the core._

bench update --reset
just recreates the patches.txt file, so it fails again on the same 6

bench --site site1.local migrate
works OK on all the “good” patches, ie. if the “bad” ones are commented out.

System is technically usable, but I’d like it to not need manual intervention if possible. Any pointers appreciated. (I don’t know enough about the correct usage of git, so maybe that’s what I need to learn??)

Thanks

An update on this problem…

  • Father, forgive me, for I have sinned…
  • I added/ran the following SQL’s to get this to work without any errors.
    • bench update --reset

I am pretty sure that this is a WORST practice - and apologise profusely if that’s true. However, I now need to ask the community IF, and how I should repair/undo this, or if the next updates will just automatically correct the DB changes?

#v8_0.move_account_head_from_account_to_warehouse_for_inventory
alter table tabAccount add column warehouse varchar(140) DEFAULT NULL;

#v8_0.update_stock_qty_value_in_bom_item
alter table tabBOM Explosion Item add column qty decimal(18,6) NOT NULL DEFAULT ‘0.000000’;

#v8_7.make_subscription_from_recurring_data
alter table tabSales Order
add column IF NOT EXISTS end_date date DEFAULT NULL
, add column IF NOT EXISTS next_date date DEFAULT NULL
, add column IF NOT EXISTS recurring_type varchar(140) DEFAULT NULL
, add column IF NOT EXISTS recurring_id varchar(140) DEFAULT NULL
, add column IF NOT EXISTS notify_by_email int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS notification_email_address longtext
, add column IF NOT EXISTS recurring_print_format varchar(140) DEFAULT NULL
, add column IF NOT EXISTS repeat_on_day_of_month int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS submit_on_creation int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS is_recurring int(1) NOT NULL DEFAULT ‘0’
;
alter table tabSales Invoice
add column IF NOT EXISTS end_date date DEFAULT NULL
, add column IF NOT EXISTS next_date date DEFAULT NULL
, add column IF NOT EXISTS recurring_type varchar(140) DEFAULT NULL
, add column IF NOT EXISTS recurring_id varchar(140) DEFAULT NULL
, add column IF NOT EXISTS notify_by_email int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS notification_email_address longtext
, add column IF NOT EXISTS recurring_print_format varchar(140) DEFAULT NULL
, add column IF NOT EXISTS repeat_on_day_of_month int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS submit_on_creation int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS is_recurring int(1) NOT NULL DEFAULT ‘0’
;
alter table tabPurchase Order
add column IF NOT EXISTS end_date date DEFAULT NULL
, add column IF NOT EXISTS next_date date DEFAULT NULL
, add column IF NOT EXISTS recurring_type varchar(140) DEFAULT NULL
, add column IF NOT EXISTS recurring_id varchar(140) DEFAULT NULL
, add column IF NOT EXISTS notify_by_email int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS notification_email_address longtext
, add column IF NOT EXISTS recurring_print_format varchar(140) DEFAULT NULL
, add column IF NOT EXISTS repeat_on_day_of_month int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS submit_on_creation int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS is_recurring int(1) NOT NULL DEFAULT ‘0’
;
alter table tabPurchase Invoice
add column IF NOT EXISTS end_date date DEFAULT NULL
, add column IF NOT EXISTS next_date date DEFAULT NULL
, add column IF NOT EXISTS recurring_type varchar(140) DEFAULT NULL
, add column IF NOT EXISTS recurring_id varchar(140) DEFAULT NULL
, add column IF NOT EXISTS notify_by_email int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS notification_email_address longtext
, add column IF NOT EXISTS recurring_print_format varchar(140) DEFAULT NULL
, add column IF NOT EXISTS repeat_on_day_of_month int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS submit_on_creation int(1) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS is_recurring int(1) NOT NULL DEFAULT ‘0’
;

#v8_10/change_default_customer_credit_days.py
alter table tabCustomer
add column IF NOT EXISTS credit_days int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS credit_days_based_on varchar(140) DEFAULT NULL
;
alter table tabSupplier
add column IF NOT EXISTS credit_days int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS credit_days_based_on varchar(140) DEFAULT NULL
;
alter table tabSupplier Type
add column IF NOT EXISTS credit_days int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS credit_days_based_on varchar(140) DEFAULT NULL
;

#/v9_1/create_issue_opportunity_type.py
alter table tabOpportunity
add column IF NOT EXISTS enquiry_type varchar(140) DEFAULT ‘Sales’
;

#/v10_0/set_default_payment_terms_based_on_company.py
alter table tabCompany
add column IF NOT EXISTS credit_days int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS credit_days_based_on varchar(140) DEFAULT NULL
;
alter table tabCustomer Group
add column IF NOT EXISTS credit_days int(11) NOT NULL DEFAULT ‘0’
, add column IF NOT EXISTS credit_days_based_on varchar(140) DEFAULT NULL
;