1.17.2 -> 1.20.4 (mysql) Unknown column 'scope' in 'field list' #11702

Open
opened 2025-11-02 09:45:13 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @working-name on GitHub (Sep 22, 2023).

Description

I don't mess with it much, I just update every now and then. Now that I did, it seems to have forgotten to do some migration script or something. Missing a column.

Gitea Version

1.20.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://privatebin.io/?197d5f399e33a875#7B4vZPFE4uVafEJZYrt2sV2eB7mdaG9MF6A4pFgWwkNW

Screenshots

image

Git Version

git version 2.20.1

Operating System

Debian 10.13

How are you running Gitea?

Go executable from github releases, via systemd.

Database

mysql

Originally created by @working-name on GitHub (Sep 22, 2023). ### Description I don't mess with it much, I just update every now and then. Now that I did, it seems to have forgotten to do some migration script or something. Missing a column. ### Gitea Version 1.20.4 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist https://privatebin.io/?197d5f399e33a875#7B4vZPFE4uVafEJZYrt2sV2eB7mdaG9MF6A4pFgWwkNW ### Screenshots <img width="1460" alt="image" src="https://github.com/go-gitea/gitea/assets/16505052/468b17ce-fe54-4aa5-a3bf-7e436c4799d6"> ### Git Version git version 2.20.1 ### Operating System Debian 10.13 ### How are you running Gitea? Go executable from github releases, via systemd. ### Database mysql
GiteaMirror added the type/bug label 2025-11-02 09:45:13 -06:00
Author
Owner

@lunny commented on GitHub (Sep 23, 2023):

I don't know how your system encountered that, because according models/migrations/v1_19/v239.go , the migration should have done it work.

@lunny commented on GitHub (Sep 23, 2023): I don't know how your system encountered that, because according models/migrations/v1_19/v239.go , the migration should have done it work.
Author
Owner

@working-name commented on GitHub (Sep 23, 2023):

Cool. So to fix it should I run whatever is in there manually?

@working-name commented on GitHub (Sep 23, 2023): Cool. So to fix it should I run whatever is in there manually?
Author
Owner

@working-name commented on GitHub (Sep 23, 2023):

Dumped the database and I can see this for

CREATE TABLE `repository` (
[...]
`num_action_runs` int(11) NOT NULL DEFAULT 0,

It also gets data inserted while mentioning num_action_runs. However, GetRepositoryByName gets Error 1054 (42S22): Unknown column 'num_action_runs' in 'field list'. It kills everything including pushes and clones, not just the web interface.

I've grepped all the migrations and none of them have num_action_runs. In fact there's a single spot in the whole source code that mentions it, and that's models/actions/run.go.

Not sure how to get this going again.

@working-name commented on GitHub (Sep 23, 2023): Dumped the database and I can see this for ```sql CREATE TABLE `repository` ( [...] `num_action_runs` int(11) NOT NULL DEFAULT 0, ``` It also gets data inserted while mentioning `num_action_runs`. However, `GetRepositoryByName` gets `Error 1054 (42S22): Unknown column 'num_action_runs' in 'field list'`. It kills everything including pushes and clones, not just the web interface. I've grepped all the migrations and none of them have `num_action_runs`. In fact there's a single spot in the whole source code that mentions it, and that's `models/actions/run.go`. Not sure how to get this going again.
Author
Owner

@lunny commented on GitHub (Sep 23, 2023):

It's in models/migrations/v1_19/v240.go. How did you upgrade your Gitea?

@lunny commented on GitHub (Sep 23, 2023): It's in `models/migrations/v1_19/v240.go`. How did you upgrade your Gitea?
Author
Owner

@working-name commented on GitHub (Sep 23, 2023):

By skipping the most important part - backing up before 🤦‍♂️. It's not a big issue, I can rebuild the installation but if it can be fixed that'd be easier.

Stopped gitea via systemctl, linked the new self-contained binary downloaded from github releases, and then systemctl start gitea. It ran its migration thing but didn't quite have it done.

I wonder if it's an index issue since the sql dump shows the proper fields (I've compared a blank 1.20 install db dump to a dump from the failed one).

@working-name commented on GitHub (Sep 23, 2023): By skipping the most important part - backing up before 🤦‍♂️. It's not a big issue, I can rebuild the installation but if it can be fixed that'd be easier. Stopped gitea via systemctl, linked the new self-contained binary downloaded from github releases, and then systemctl start gitea. It ran its migration thing but didn't quite have it done. I wonder if it's an index issue since the sql dump shows the proper fields (I've compared a blank 1.20 install db dump to a dump from the failed one).
Author
Owner

@working-name commented on GitHub (Sep 27, 2023):

Okay so far so good. It seems it was the indices that were borked. Maybe look into that for future migrations.

@working-name commented on GitHub (Sep 27, 2023): Okay so far so good. It seems it was the indices that were borked. Maybe look into that for future migrations.
Author
Owner

@working-name commented on GitHub (Oct 15, 2023):

Actually, no, it's screwed up ever since. It sometimes 'loses' tokens, and it fails authentication 9/10 times using a brand new token. Odd behavior overall. It's not doing well.

What do you do in cases like this?

@working-name commented on GitHub (Oct 15, 2023): Actually, no, it's screwed up ever since. It sometimes 'loses' tokens, and it fails authentication 9/10 times using a brand new token. Odd behavior overall. It's not doing well. What do you do in cases like this?
Author
Owner

@papaUbu commented on GitHub (Mar 26, 2024):

I have the same issue upgrading from version 1.18.3 to version 1.21.9 using the script given here : https://github.com/go-gitea/gitea/blob/release/v1.21/contrib/upgrade.sh

Outputs :
2024/03/26 17:02:25 cmd/dump.go:306:runDump() [I] Dumping database...
Failed to dump database: Error 1054 (42S22): Unknown column 'scope' in 'field list'
2024/03/26 17:02:25 cmd/dump.go:173:fatal() [F] Failed to dump database: Error 1054 (42S22): Unknown column 'scope' in 'field list'

@papaUbu commented on GitHub (Mar 26, 2024): I have the same issue upgrading from version 1.18.3 to version 1.21.9 using the script given here : https://github.com/go-gitea/gitea/blob/release/v1.21/contrib/upgrade.sh Outputs : 2024/03/26 17:02:25 cmd/dump.go:306:runDump() [I] Dumping database... Failed to dump database: Error 1054 (42S22): Unknown column 'scope' in 'field list' 2024/03/26 17:02:25 cmd/dump.go:173:fatal() [F] Failed to dump database: Error 1054 (42S22): Unknown column 'scope' in 'field list'
Author
Owner

@working-name commented on GitHub (Mar 26, 2024):

I don't know if this helps at all @papaUbu - I run my mysql in a proxmox container, manual install and all. It somehow got its storage corrupted. I created a new proxmox container (LXC), installed mariadb on it, and imported the database into the new instance. It seems to be stable so far it has not gotten confused about api keys and such again. Fingers crossed.

@working-name commented on GitHub (Mar 26, 2024): I don't know if this helps at all @papaUbu - I run my mysql in a proxmox container, manual install and all. It somehow got its storage corrupted. I created a new proxmox container (LXC), installed mariadb on it, and imported the database into the new instance. It seems to be stable so far it has not gotten confused about api keys and such again. Fingers crossed.
Author
Owner

@papaUbu commented on GitHub (Mar 26, 2024):

Thank you @working-name.

Anyway, I managed to find a workaround (for my specific case).

I found in the models/migrations/migrations.go file that between my version (1.18.3) and the newest that I tried to upgrade to (1.21.9) the scope column had been added to the access_token table. It was at version 1.19 (go-gitea/gitea/models/migrations/v1_19/v239.go).

I translated the query made inside the AddScopeForAccessTokens function to a mysql query, connected to my gitea database and made the query.

Here it is :

ALTER TABLE access_token ADD COLUMN scope VARCHAR(255) DEFAULT 'all,sudo';
UPDATE access_token SET scope = 'all,sudo' WHERE scope IS NULL OR scope = '';

Then, re-ran the update and it was successful.

Hope this helps.

@papaUbu commented on GitHub (Mar 26, 2024): Thank you @working-name. Anyway, I managed to find a workaround (for my specific case). I found in the models/migrations/migrations.go file that between my version (1.18.3) and the newest that I tried to upgrade to (1.21.9) the `scope` column had been added to the `access_token` table. It was at version 1.19 (go-gitea/gitea/models/migrations/v1_19/v239.go). I translated the query made inside the AddScopeForAccessTokens function to a mysql query, connected to my gitea database and made the query. Here it is : ``` ALTER TABLE access_token ADD COLUMN scope VARCHAR(255) DEFAULT 'all,sudo'; UPDATE access_token SET scope = 'all,sudo' WHERE scope IS NULL OR scope = ''; ``` Then, re-ran the update and it was successful. Hope this helps.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11702