I'm totally new to postgres. On my postgres db I've created a database:
CREATE ROLE gitea WITH LOGIN PASSWORD 'gitea';
CREATE DATABASE gitea WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
CREATE SCHEMA gitea;
GRANT ALL ON SCHEMA gitea TO gitea;
ALTER USER gitea SET search_path=gitea;
Running the gitea application I do get this error, which says schema is not existing. What did I do wrong on the db?
2023/06/05 08:12:13 .../[email protected]/app.go:277:Run() [I] PING DATABASE postgresschema
2023/06/05 08:12:13 models/db/engine.go:190:InitEngineWithMigration() [I] [SQL] SELECT tablename FROM pg_tables WHERE schemaname = $1 [gitea] - 3.310737ms
2023/06/05 08:12:13 ...ations/migrations.go:518:Migrate() [I] [SQL] CREATE TABLE IF NOT EXISTS "gitea"."version" ("id" BIGSERIAL PRIMARY KEY NOT NULL, "version" BIGINT NULL); [] - 512.953µs
2023/06/05 08:12:13 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: sync: pq: schema "gitea" does not exist
psql, add a line with\c giteabeforeCREATE SCHEMA gitea;to connect to the new db and create the schema there.select * from information_schema.schematato see schemas available to you in the db you're currently connected to.\c giteato a sql file, which includes the CREATE commands shown in my post?psql. It is a client-specific meta-command. To make it portable, you need to split your script into one that sets up the db operating from on of the pre-existing databases (the top two lines), and another script that's meant to run already within the newly setup db (3rd line onwards). Then setup the client to open a separate session for the second script.\cin your sql file, you can specify both database and user directly as:psql -d gitea -U gitea ...