India Compliance installation issue while migrating from V13 to V14

HI @snv,

I am trying to migrate to V14 from V13 that uses GST. I am able to do bench get the app with correct version 14 (India Compliance version india_compliance 14.26.5).
When I try to install the app on the site, I get the following error. Seems like the log migration is failing either due to query format or because of lots of existing data. How to resolve this?

bench --site migratedesk.local install-app india_compliance
App erpnext already installed

Installing india_compliance...
Updating DocTypes for india_compliance: [========================================] 100%
Setting up Income Tax...
Setting up GST...
Patching Existing Data...
 Please check for addresses without GST Category and set approporiate values.

Installation for India Compliance failed due to an error. Please try re-installing the app or report the issue on https://github.com/resilient-tech/india-compliance/issues/new if not resolved.
An error occurred while installing india_compliance: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")
Traceback (most recent call last):
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 760, in _write_bytes
    self._sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 400, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 305, in install_app
    frappe.get_attr(after_install)()
  File "apps/india_compliance/india_compliance/install.py", line 73, in after_install
    raise e
  File "apps/india_compliance/india_compliance/install.py", line 62, in after_install
    run_post_install_patches()
  File "apps/india_compliance/india_compliance/install.py", line 86, in run_post_install_patches
    frappe.get_attr(f"india_compliance.patches.post_install.{patch}.execute")()
  File "apps/india_compliance/india_compliance/patches/post_install/update_e_invoice_fields_and_logs.py", line 17, in execute
    migrate_e_invoice_request_log()
  File "apps/india_compliance/india_compliance/patches/post_install/update_e_invoice_fields_and_logs.py", line 204, in migrate_e_invoice_request_log
    frappe.db.bulk_insert(
  File "apps/frappe/frappe/database/database.py", line 1416, in bulk_insert
    query.columns(fields).insert(*values_to_insert).run()
  File "apps/frappe/frappe/query_builder/utils.py", line 87, in execute_query
    result = frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
  File "apps/frappe/frappe/database/database.py", line 244, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
    self._execute_command(COMMAND.COM_QUERY, sql)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 829, in _execute_command
    self.write_packet(sql[:packet_size])
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 684, in write_packet
    self._write_bytes(data)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 763, in _write_bytes
    raise err.OperationalError(
pymysql.err.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")

Searching around, I could solve the problem by changing the mariadb config as follows:
SET GLOBAL max_allowed_packet=1073741824;
SET GLOBAL net_buffer_length=1048576;

After the installation, they can be reverted to the default values:
SET GLOBAL max_allowed_packet=16777216;
SET GLOBAL net_buffer_length=16384;

I am still getting the follwoing errors on all GST reports:

ModuleNotFoundError: No module named ‘erpnext.regional.report.gst_itemised_purchase_register’

ModuleNotFoundError: No module named ‘erpnext.regional.report.gst_itemised_sales_register’

ModuleNotFoundError: No module named ‘erpnext.regional.report.gst_purchase_register’

etc.

What is needed here? I have done bench clear-cache and bench migrate prior to running this.

These reports have been moved to India Compliance App.
Are these non-standard reports otherwise bench migrate would have updated the reports.
You can check all the Reports in the Report List.

Thanks. That helped. I realized I have an unfiltered fixture on reports in my custom app that was also running while I did bench migrate. Potentially, the fixtures run after the on install routine and therefore, the reports were getting reassigned to regional module which is no longer there.

This brings me to an important question - what is the best way to export customization? Multiple threads on this forum raise the question but no documentation with authority demystifies the customization game.

One of the solutions can be Creating a separate App to manage the customisations.

Thats what I did. The problem I faced was due to a fixture I added in hooks for doctype = reports but without any filters. So, it was exporting all the reports in the system. This was overwriting the module update done by India Compliance install patch. I have added filters by name for my custom reports in the hooks and it no longer overwrite the patched value. But it also mean that for all other doctype that I am exporting fixture for, I need to be careful else it may override all future updates as well.

Once you set it, you need to exit and start a new session for these values to take effect. Check the value using the following commands:

SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
SHOW SESSION VARIABLES LIKE 'net_buffer_length';

Yes, you should remove all the fixtures related to the India Compliance App if not required.Because multiple issues have been reported due to this.