Migration from OC to NC fails with psql

Started a migration from owncloud 10.0.8 to nextcloud as suggested on https://nextcloud.com/migration/

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: https://github.com/nextcloud/server/issues/4504#issuecomment-364741491

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”.