Open hazayan opened 9 months ago
Hi! Is this only needed in Knex? Since we only use it for migrations and the application itself uses Waterline. But in any case, PRs are always welcome :)
Actually I found a much easier solution with no code change required. At least for the docker
based deployment. Obviously this solution doesn't change the fact that the database url, database adapter and database schema should be made explicitly configurable along with sane defaults.
So the solution in question is to override the /app/config/env/production.js
with a local version of the same file having the diff below, in the docker-compose.yml
section for the planka
app, effectively allowing for the schema name to be passed on as an environment variable.
diff --git a/server/config/env/production.js b/server/config/env/production.js
index bed4f31..55e40ee 100644
--- a/server/config/env/production.js
+++ b/server/config/env/production.js
@@ -50,6 +50,9 @@ module.exports = {
*/
default: {
+ url: process.env.DATABASE_URL,
+ adapter: process.env.DATABASE_ADAPTER,
+ schemaName: process.env.DATABASE_SCHEMA,
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
/**
Currently when a planka database is created, or queried, knex defaults to using public as the schema name. Would it be acceptable to allow the possibility to pass a custom schema name through an environment variable to knex, the same way the database connection url is ? (I can create a PR for that if this gets approved).