Skip to content

Migration failed by "error in table task after rename: duplicate column name: message" #17328

Closed
@wxiaoguang

Description

@wxiaoguang

Gitea Version

1.15.4

Description

Many users report that the migration fails:

2021/10/16 08:45:14 ...ations/migrations.go:422:Migrate() [I] [SQL] ALTER TABLE `task` RENAME COLUMN errors TO message [] - 6.592953ms
2021/10/16 08:45:14 ...ations/migrations.go:422:Migrate() [I] [SQL] ROLLBACK [] - 113.064µs
2021/10/16 08:45:14 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: migrate: do migrate: error in table task after rename: duplicate column name: message
2021/10/16 08:45:14 routers/common/db.go:34:InitDBEngine() [I] Backing off for 3 seconds
2021/10/16 08:45:17 routers/common/db.go:27:InitDBEngine() [I] ORM engine initialization attempt #2/10...

Removing the message field in task table resolves this problem and can complete the migration.

The problem seems to be caused by Gitea accessed the task ORM too early (before migration), so the task table was changed (message was added while error also exists) before the migration and then the conflict occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions