After upgrade docker image to 0.165.0, during startup I got this error:
Initializing n8n process
UserSettings were generated and saved to: /home/node/.n8n/config
INFO: Started migration for execution entity indexes.
Depending on the number of saved executions, it may take a while.
There was an error initializing DB: "Can't DROP 'IDX_c4d999a5e90784e8caccf5589d'; check that column/key exists"
Stopping n8n...
After investigating, I solved creating this index manually on database:
create index IDX_c4d999a5e90784e8caccf5589d on execution_entity (workflowId);
After this, n8n run migrations as expected.