requarks / wiki

Wiki.js | A modern and powerful wiki app built on Node.js
https://js.wiki
GNU Affero General Public License v3.0
23.92k stars 2.62k forks source link

Fix postgres db custom schema option not working #6708

Open bergerkiller opened 9 months ago

bergerkiller commented 9 months ago

We encountered an issue when trying to configure a postgres DB schema, which was needed for integration with supabase. This was caused by knex migration scripts not having this same schema configured, and this custom schema not being created at startup.

This PR fixes both issues and allows for a successful startup and initialization of the wiki server.

I did notice that this option, while it exists in the code, isn't documented in the docs. It is set by using a config.yml with db.schema set, and I don't think it has an env parsing default. This might be something worth improving in the future.

bergerkiller commented 8 months ago

Added a change to only create the custom schema if it doesn't already exist. CREATE IF NOT EXISTS does not work by itself because the user requires CREATE permission on the database for it to work. When granting limited priviliges to the wiki database user this is undesirable.