gitea: gitea does not start - can not find public schema
- Gitea version: 1.5.2 (docker)
- Git version: 2.19.1
- Operating system: Debian
- Database (use
[x]):- PostgreSQL
- Can you reproduce the bug at https://try.gitea.io:
- Not relevant
Hello, I have multiple instances for gitea. Every installation should use one big postgres database with his own schema.
So I create for one instance his own schema and username and changed the search_path to disable querying statements to the public schema, because I don’t want, that any application or instance create his schema into public.
Here my psql statements
CREATE SCHEMA gitea;
CREATE ROLE gitea WITH LOGIN;
ALTER USE gitea SET search_path=gitea;
GRANT ALL ON SCHEMA gitea to gitea;
After installation gitea does not start and I get in my logs every time the same error.
root@vgttp:/srv/docker/gitea_01/data/gitea/log# tailf xorm.log
2018/10/23 20:37:33 [I] PING DATABASE postgres
2018/10/23 20:37:33 [I] [SQL] SELECT tablename FROM pg_tables WHERE schemaname = $1 AND tablename = $2 []interface {}{"public", "version"}
2018/10/23 20:37:33 [I] [SQL] CREATE TABLE IF NOT EXISTS "version" ("id" BIGSERIAL PRIMARY KEY NOT NULL, "version" BIGINT NULL)
2018/10/23 20:37:33 [I] [SQL] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = $1 AND table_name = $2 AND column_name = $3 [public version id]
2018/10/23 20:37:33 [I] [SQL] ALTER TABLE "version" ADD "id" BIGSERIAL PRIMARY KEY NOT NULL ;
Gitea look in the public schema? I have installed the instance into his own schema! How can I change in my docker-compose or app.ini the schema name?
Volker
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
@lunny It turns out
xormalready handled the case correctly; only Gitea didn’t useengine.SetSchema()to specify a different one. PR’d at #8819 (no need for weirdALTER userstatements 😁)@lunny The solution is much much simpler 😁. I’ve just tested it locally. The problem is that xorm is forcing the
publicschema in some queries.What I did:
notpublic).alter table access set schema notpublic;, etc.)ALTER USER gitea SET search_path = notpublic;.DefaultPostgresSchemaandpostgresPublicSchematonotpublic.IMHO #3348 is trying to change all queries unnecessarily, and
xormalmost handles this. There are only a few problems:DefaultPostgresSchemais initialized to"public"instead ofpostgresPublicSchema, so no compilation customization (-X) can be used.Engine.tbNameWithSchema()usespostgresPublicSchemainstead ofdb.Schema, so the two values are not synchronized.If you agree with my analysis, I could pass a PR to xorm for the first two.
@guillep2k Good catch! And if you can add a new database test with non-public schema of postgres, that’s better. 😃