Migration from OC to NC fails with psql

Started a migration from owncloud 10.0.8 to nextcloud as suggested on Nextcloud - Migration guide

System is debian 9.5, database is postgresql 9.6

Running the web migration and everything went fine.

Did the “occ upgrade” and it fails as already somewhere:

Updating database schema
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE oc_filecache ALTER fileid TYPE SERIAL’:

SQLSTATE[42704]: Undefined object: 7 ERROR:  type "serial" does not exist
Update failed

I read here to some psql commands: Update to 11.0.3 failed · Issue #4504 · nextcloud/server · GitHub

but I don’t have even basic knowledge with databases.

So I did:

sudo -i -u postgres psql

and then the failure:

postgres=# ALTER TABLE oc_activity ALTER activity_id TYPE int;
ERROR: relation “oc_activity” does not exist

Any help appreciated. Thanks in advance.

Ok, finally I found out. The solution was to:

postgres=# \connect owncloud
You are now connected to database “owncloud” as user “postgres”.