Bench upgrade error: _mysql_exceptions.OperationalError: (1048, "Column 'in_dialog' cannot be null")

I finally was able to migrate to V9.
This is what I did:

Install ERPnext
I installed a complete new instance of erpnext

  1. Download the install script
    wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
  2. Run the install script
    sudo python install.py --production --user frappe

Restore
Copy content of site1.local (or your site directory) to the corresponding directory in the new created instance of frappe-bench.

Copy your last backup of your database to /frappe/frappe-bench/
Something like 20170421_091326_2a418746_database.sql

Open terminal
Type “sudo su”
Go to the frappe-bench folder
“cd /home/frappe/frappe-bench“
Run the following bench commands (to restore db and run latest)
If needed install extensions:
install base_vat
bench get-app base_vat GitHub - saguas/frappe_base_vat: Repository for frappe base vat application
bench install-app base_vat

install poll
bench get-app poll GitHub - frappe/poll: Online Polling App
bench install-app poll

restore ERPnext database
bench --force restore sqlfile.sql (sqlfile.sql = name of the recent backupfile)

bench mysql
ALTER TABLE tabDocType ADD COLUMN restrict_to_domain VARCHAR(40);
bench --force reload-doc core doctype page

You will need to copy the encryption keys from your old server. (they will be there in bench/sites/sitename/site_config.json)

bench build
bench migrate
bench restart