Patch #43457
openPostgresql installation documentation: Public schema and schema_search_path
0%
Description
The wiki says to put the database_schema in the schema_search_path and default to public.
But according to ActiveRecord Documentation on schema_search_path, if omitted the default will be whatever is configured for the database. According to PostgreSQL documentation it will be default to '$user', public.
Meaning that by default, if omitted, the first looked up schema will be the $user schema, in other words the redmine schema if the user is 'redmine'.
Since PostgreSQL 15 the CREATE privilege is not given by default to the owner of the database on the public schema (see Defect #37986: postgresql 15: additional steps required while initializing database). Additionally I guess it is now a good practice to not put production tables within the public schema. I think it would be great to modify the installation procedure for postgresSQL to create a 'redmine' schema that the redmine user will own and have all privileges on it.
Coherently also modify default schema_search_path in the wiki and the source:trunk/config/database.yml.example.
I note that the example database.yml doesn't mention the schema_search_path in the PostgreSQL section.
I suggest the following
1. Add the creation of a 'redmine' schema in the redmine database to the installation procedure. There's no need to give additional permissions to redmine role because he will own this schema with default privileges (this should fix Defect #37986: postgresql 15: additional steps required while initializing database).
CREATE SCHEMA AUTHORIZATION redmine;
https://www.postgresql.org/docs/18/sql-createschema.html
2. Make the database.yml.example and the redmine wiki consistent. Either omit the schema_search_path option since it will by default be '$user', public and so the redmine schema will be looked up first. Or modify database.yml.example and the redmine wiki to correctly default schema_search_path to "'$user', public" or just "redmine, public" or redmine
The syntax is "'$user', public" $user must be quoted and if so all the parameter too.
Example current behaviour:
All tables are supposed in the public schema on a PostgreSQL redmine database with a redmine role owning the database (typical current installation), you can check claimed behaviour by changing the schema of a table and the config/database.yml with for example:
ALTER TABLE settings SET SCHEMA redmine;
The app will no longer work with a database.yml specifying 'public' as schema_search_path but will if the parameter is omitted.
What do you think?
I faced this problematic when switching from mysql to postgresql.
No data to display