database issue after updating #1086

Closed
opened 2025-11-02 03:47:47 -06:00 by GiteaMirror · 19 comments
Owner

Originally created by @AntouanK on GitHub (Sep 21, 2017).

  • Gitea version (or commit ref):
  • Git version:
  • Operating system: Linux arch (using docker containers)
  • 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:

Description

After updating the docker images, I get this in the docker-compose logs

gitea_1     | 2017/09/21 15:13:08 [T] Custom path: /data/gitea
gitea_1     | 2017/09/21 15:13:08 [T] Log path: /data/gitea/log
postgres_1  | ERROR:  column "can_push" of relation "protected_branch" does not exist at character 31
postgres_1  | STATEMENT:  UPDATE "protected_branch" SET "can_push" = $1, "updated_unix" = $2 
...

It keeps repeating those 4 lines, and the web interface won't load.
Any ideas what's wrong?

Thanks

Originally created by @AntouanK on GitHub (Sep 21, 2017). - Gitea version (or commit ref): - Git version: - Operating system: Linux arch (using docker containers) - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description After updating the docker images, I get this in the docker-compose logs ``` gitea_1 | 2017/09/21 15:13:08 [T] Custom path: /data/gitea gitea_1 | 2017/09/21 15:13:08 [T] Log path: /data/gitea/log postgres_1 | ERROR: column "can_push" of relation "protected_branch" does not exist at character 31 postgres_1 | STATEMENT: UPDATE "protected_branch" SET "can_push" = $1, "updated_unix" = $2 ... ``` It keeps repeating those 4 lines, and the web interface won't load. Any ideas what's wrong? Thanks
GiteaMirror added the type/bug label 2025-11-02 03:47:47 -06:00
Author
Owner

@daviian commented on GitHub (Sep 21, 2017):

Unfortunately introduced with https://github.com/go-gitea/gitea/pull/2560

@lafriks PR https://github.com/go-gitea/gitea/pull/2451 dropped column can_push

@daviian commented on GitHub (Sep 21, 2017): Unfortunately introduced with https://github.com/go-gitea/gitea/pull/2560 @lafriks PR https://github.com/go-gitea/gitea/pull/2451 dropped column `can_push`
Author
Owner

@lafriks commented on GitHub (Sep 21, 2017):

Oh, I thought it did not drop column. I will fix my migration just then to add it back

@lafriks commented on GitHub (Sep 21, 2017): Oh, I thought it did not drop column. I will fix my migration just then to add it back
Author
Owner

@AntouanK commented on GitHub (Sep 21, 2017):

So how can I fix it?

@AntouanK commented on GitHub (Sep 21, 2017): So how can I fix it?
Author
Owner

@daviian commented on GitHub (Sep 21, 2017):

@AntouanK @lafriks said he will change his migration to fix this.

As you updated to current master, I guess it isn't a productive system?

@daviian commented on GitHub (Sep 21, 2017): @AntouanK @lafriks said he will change his migration to fix this. As you updated to current master, I guess it isn't a productive system?
Author
Owner

@AntouanK commented on GitHub (Sep 22, 2017):

It's a server at home for my personal projects. But it's blocking all my repos now!
Should I revert to an older docker image manually?

@AntouanK commented on GitHub (Sep 22, 2017): It's a server at home for my personal projects. But it's blocking all my repos now! Should I revert to an older docker image manually?
Author
Owner

@ghost commented on GitHub (Sep 22, 2017):

I don't think that reverting to an older docker image will fix your issue. The can_push column in the protected_branch table has been deleted. I recreated the column in the database and now I have gitea running again with the latest docker image.

@ghost commented on GitHub (Sep 22, 2017): I don't think that reverting to an older docker image will fix your issue. The can_push column in the protected_branch table has been deleted. I recreated the column in the database and now I have gitea running again with the latest docker image.
Author
Owner

@AntouanK commented on GitHub (Sep 22, 2017):

I just pulled the latest, and I still get those lines. ( and the web interface is not working )

gitea_1     | 2017/09/22 08:26:21 [T] Custom path: /data/gitea
gitea_1     | 2017/09/22 08:26:21 [T] Log path: /data/gitea/log
postgres_1  | ERROR:  column "can_push" of relation "protected_branch" does not exist at character 31
postgres_1  | STATEMENT:  UPDATE "protected_branch" SET "can_push" = $1, "updated_unix" = $2 
@AntouanK commented on GitHub (Sep 22, 2017): I just pulled the latest, and I still get those lines. ( and the web interface is not working ) ``` gitea_1 | 2017/09/22 08:26:21 [T] Custom path: /data/gitea gitea_1 | 2017/09/22 08:26:21 [T] Log path: /data/gitea/log postgres_1 | ERROR: column "can_push" of relation "protected_branch" does not exist at character 31 postgres_1 | STATEMENT: UPDATE "protected_branch" SET "can_push" = $1, "updated_unix" = $2 ```
Author
Owner

@daviian commented on GitHub (Sep 22, 2017):

Like @nellonican said you have to create the can_push column manually afterwards as a temporary fix

@daviian commented on GitHub (Sep 22, 2017): Like @nellonican said you have to create the `can_push` column manually afterwards as a temporary fix
Author
Owner

@ghost commented on GitHub (Sep 22, 2017):

@AntouanK What I did was:

Log in to my postgres database and give the following commands:

gitea-# \c gitea
gitea-# alter table protected_branch add column "can_push" boolean;
gitea-# \q

After that i had to do a docker-compose down and docker-compose up -d

@ghost commented on GitHub (Sep 22, 2017): @AntouanK What I did was: Log in to my postgres database and give the following commands: ```bash gitea-# \c gitea gitea-# alter table protected_branch add column "can_push" boolean; gitea-# \q ``` After that i had to do a `docker-compose down` and `docker-compose up -d`
Author
Owner

@daviian commented on GitHub (Sep 22, 2017):

@nellonican @AntouanK You should set the column to NOT NULL DEFAULT false as well

@daviian commented on GitHub (Sep 22, 2017): @nellonican @AntouanK You should set the column to `NOT NULL DEFAULT false` as well
Author
Owner

@ghost commented on GitHub (Sep 22, 2017):

@daviian Thx. Will do.

@ghost commented on GitHub (Sep 22, 2017): @daviian Thx. Will do.
Author
Owner

@AntouanK commented on GitHub (Sep 22, 2017):

I never used postgres, can you tell me how to log in?
I guess I can do docker exec on the running postgres container somehow to run those commands?

@AntouanK commented on GitHub (Sep 22, 2017): I never used postgres, can you tell me how to log in? I guess I can do `docker exec` on the running postgres container somehow to run those commands?
Author
Owner

@ghost commented on GitHub (Sep 22, 2017):

@AntouanK

docker run -it --rm --link gitea_db_1:postgres postgres:alpine psql -postgres -U postgres

The gitea_db_1 part should be the name of your docker container.

@ghost commented on GitHub (Sep 22, 2017): @AntouanK ```bash docker run -it --rm --link gitea_db_1:postgres postgres:alpine psql -postgres -U postgres ``` The `gitea_db_1` part should be the name of your docker container.
Author
Owner

@AntouanK commented on GitHub (Sep 22, 2017):

That didn't work for me.
Here's how I did it.

docker exec -it gitea_postgres_1 /bin/bash to get access to the postgres container.
psql --username="dbuser" -d "giteadb" to open that interactive shell.
then run \c giteadb and alter table protected_branch add column "can_push" boolean;

seems to be working now, thanks.

@AntouanK commented on GitHub (Sep 22, 2017): That didn't work for me. Here's how I did it. `docker exec -it gitea_postgres_1 /bin/bash` to get access to the postgres container. `psql --username="dbuser" -d "giteadb"` to open that interactive shell. then run `\c giteadb` and `alter table protected_branch add column "can_push" boolean;` seems to be working now, thanks.
Author
Owner

@ghost commented on GitHub (Sep 22, 2017):

@AntouanK, as @daviian mentioned you should also do:

alter table protected_branch alter column "can_push" set DEFAULT false;
alter table protected_branch alter column "can_push" set NOT NULL;
@ghost commented on GitHub (Sep 22, 2017): @AntouanK, as @daviian mentioned you should also do: ```bash alter table protected_branch alter column "can_push" set DEFAULT false; alter table protected_branch alter column "can_push" set NOT NULL; ```
Author
Owner

@ToeiRei commented on GitHub (Sep 22, 2017):

Same problem with my environment here (official docker image on MySQL) - thanks for the hint

@ToeiRei commented on GitHub (Sep 22, 2017): Same problem with my environment here (official docker image on MySQL) - thanks for the hint
Author
Owner

@lunny commented on GitHub (Sep 22, 2017):

@lafriks I think this needs a PR to fix.

@lunny commented on GitHub (Sep 22, 2017): @lafriks I think this needs a PR to fix.
Author
Owner

@mmarif4u commented on GitHub (Sep 22, 2017):

I was getting the same.

[...itea/routers/init.go:55 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Error 1054: Unknown column 'can_push' in 'field list'

The table(MySQL) hack from @nellonican fixed one issue:

Alter table protected_branch add column can_push boolean NOT NULL DEFAULT false;

Then hit by this one:

 [...els/issue_indexer.go:21 InitIssueIndexer()] [E] Unable to open issues indexer (indexers/issues.bleve). If the error is due to incompatible versions, try deleting the indexer files; gitea will recreate them with the appropriate version the next time it runs. Deleting the indexer files will not result in loss of data.

Have to delete issues.bleve dir inside indexers. And it starts normally afterwards.

@mmarif4u commented on GitHub (Sep 22, 2017): I was getting the same. ```bash [...itea/routers/init.go:55 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Error 1054: Unknown column 'can_push' in 'field list' ``` The table(MySQL) hack from @nellonican fixed one issue: ```bash Alter table protected_branch add column can_push boolean NOT NULL DEFAULT false; ``` Then hit by this one: ```bash [...els/issue_indexer.go:21 InitIssueIndexer()] [E] Unable to open issues indexer (indexers/issues.bleve). If the error is due to incompatible versions, try deleting the indexer files; gitea will recreate them with the appropriate version the next time it runs. Deleting the indexer files will not result in loss of data. ``` Have to delete `issues.bleve` dir inside indexers. And it starts normally afterwards.
Author
Owner

@lafriks commented on GitHub (Sep 22, 2017):

@mmarif4u issue with bleve index is known issue and #2524 fixes it

@lafriks commented on GitHub (Sep 22, 2017): @mmarif4u issue with bleve index is known issue and #2524 fixes it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1086