Thanks for replying, I have a solution.
I searched for “Database error when running migration latest for app core” in my logs and found that one error was “Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes”
What I did:
go to database
use nextcloud;
set global innodb_large_prefix=on;
set global innodb_file_format=Barracuda;
and after that I did occ maintenance:repair
after that I had to run the updater 2 times and then it worked.