Migration Error 1091: Can't DROP 'index'; check that column/key exists #1312

Closed
opened 2025-11-02 03:56:22 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @issmirnov on GitHub (Dec 2, 2017).

  • Gitea version (or commit ref): 1.3.0
  • Git version:
  • Operating system: Ubuntu 16.06
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: 2017/12/01 19:02:23 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: DROP COLUMN index: Error 1091: Can't DROP 'index'; check that column/key exists

Description

After upgrading from 1.2.3 to 1.3.0, gitea no longer starts. Inspecting logs shows [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: DROP COLUMN index: Error 1091: Can't DROP 'index'; check that column/key exists , which seems to be coming from removeIndexColumnFromRepoUnitTable. Might be related to #2650.

One suggestion is to keep the if err != nil check, but if the error code is 1091 ignore it rather than aborting the app.

Originally created by @issmirnov on GitHub (Dec 2, 2017). - Gitea version (or commit ref): 1.3.0 - Git version: - Operating system: Ubuntu 16.06 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: `2017/12/01 19:02:23 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: DROP COLUMN index: Error 1091: Can't DROP 'index'; check that column/key exists ` ## Description After upgrading from 1.2.3 to 1.3.0, gitea no longer starts. Inspecting logs shows `[...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: DROP COLUMN index: Error 1091: Can't DROP 'index'; check that column/key exists `, which seems to be coming from [removeIndexColumnFromRepoUnitTable](https://github.com/go-gitea/gitea/blob/a79af9cf6f6828c87e6e5636fff9e9d85bce386f/models/migrations/v45.go#L21). Might be related to #2650. One suggestion is to keep the `if err != nil` check, but if the error code is 1091 ignore it rather than aborting the app.
Author
Owner

@lunny commented on GitHub (Dec 2, 2017):

but #2651 has fixed this.

@lunny commented on GitHub (Dec 2, 2017): but #2651 has fixed this.
Author
Owner

@issmirnov commented on GitHub (Dec 2, 2017):

I could be wrong at the cause. I downloaded v1.3.0 from the release tab, swapped it in to the v1.2.3 binary and then restarted the service, then got the error.

Are there any SQL commands you would like me to run to help diagnose?

@issmirnov commented on GitHub (Dec 2, 2017): I could be wrong at the cause. I downloaded v1.3.0 from the release tab, swapped it in to the v1.2.3 binary and then restarted the service, then got the error. Are there any SQL commands you would like me to run to help diagnose?
Author
Owner

@lunny commented on GitHub (Dec 2, 2017):

Yes, it's caused by your downgrade which Gitea don't support. You can just add a column named index on table repo_unit. If you have mysql, that SQL maybe

ALTER TABLE repo_unit ADD COLUMN `index` INT;
@lunny commented on GitHub (Dec 2, 2017): Yes, it's caused by your downgrade which Gitea don't support. You can just add a column named `index` on table `repo_unit`. If you have mysql, that SQL maybe ```SQL ALTER TABLE repo_unit ADD COLUMN `index` INT; ```
Author
Owner

@issmirnov commented on GitHub (Dec 3, 2017):

Thank you, was able to restore sanity. I didn't intentionally downgrade but I'm guessing my script doesn't do what I thought.

Thank you for the help!

@issmirnov commented on GitHub (Dec 3, 2017): Thank you, was able to restore sanity. I didn't intentionally downgrade but I'm guessing my script doesn't do what I thought. Thank you for the help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1312