Gitea upgrade from 1.14 to 1.16.5: column id but struct has not related field

The database is version v170 (sqlite3 gitea.db “select * from version”) which is in 1.14.0-rc1 but installing 1.14.0-rc1 shows v178 while 1.13 is documented to end at v155 meaning Gitea was installed from source at the time.

This is the log of running the following with the database. It exhibits the same kind of errors while trying to migrate from v170 to v178.

docker run --volume /tmp/gitea:/data --name gitea1 -p 8781:3000 -p 2721:22 -e GITEA__security__INSTALL_LOCK=true -e GITEA__log__LEVEL=debug -e GITEA__server__DOMAIN= -e GITEA__server__SSH_DOMAIN= -e GITEA__server__SSH_PORT=2721 -e GITEA__server__ROOT_URL= -e GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE=true -d gitea/gitea:1.14.0-rc1

v1.14.0-rc1.log (64.3 KB)

A similar problem was diagnosed in 1.13.x and someone suggested:

They are simply due to inconsistencies in the way our object-relational mapping system xorm infers schemas. It should be fixed in master with a newer version of xorm.

But the same errors happen when running with 1.16.7 so the version of xorm is not the root problem.

v1.16.7.log (35.5 KB)

Then, because the database was modified for sanitation purposes, the migration fails and prevents further investigation.

2022/05/08 18:59:48 ...ations/migrations.go:468:Migrate() [I] Migration[179]: Convert avatar url to text
2022/05/08 18:59:48 ...ations/migrations.go:468:Migrate() [I] Migration[180]: Delete credentials from past migrations
2022/05/08 18:59:48 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: migrate: migration[180]: Delete credentials from past migrations failed: readObjectStart: expect { or n, but found 2, error found in #1 byte of ...|24708d0e4c8|..., bigger context ...|24708d0e4c813402b15262e834fcc7c7|...

In order to investigate further one would need a copy of the original database.