From 83b3b41b4b41af6ef82e348a77b84469bff7eeb9 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 27 Feb 2024 13:07:39 +0100 Subject: [PATCH] Fix Generator (#5) * fixup Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina --------- Signed-off-by: Matteo Collina --- lib/generator.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/generator.js b/lib/generator.js index b4979c1..6b68744 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -11,16 +11,6 @@ const defaultConnectionString = 'postgres://postgres:postgres@127.0.0.1:5432/pos // We extend ServiceGenerator instead of DBGenerator because we // do not want to allow users to have their own migrations. class PlatformaticPgHooksGenerator extends ServiceGenerator { - getDefaultConfig () { - const defaultBaseConfig = super.getDefaultConfig() - const defaultConfig = { - db: { - connectionString: null - } - } - return Object.assign({}, defaultBaseConfig, defaultConfig) - } - getConfigFieldsDefinitions () { const serviceConfigFieldsDefs = super.getConfigFieldsDefinitions() return [ @@ -38,11 +28,12 @@ class PlatformaticPgHooksGenerator extends ServiceGenerator { async _getConfigFileContents () { const baseConfig = await super._getConfigFileContents() const packageJson = await this.getStackablePackageJson() + const dbUrlEnvVar = this.getEnvVarName('DB_URL') const config = { $schema: './stackable.schema.json', module: packageJson.name, db: { - connectionString: '{DATABASE_URL}' + connectionString: `{${dbUrlEnvVar}}` }, service: undefined } @@ -61,7 +52,7 @@ class PlatformaticPgHooksGenerator extends ServiceGenerator { } this.addEnvVars({ - DATABASE_URL: this.config.connectionString || defaultConnectionString + DB_URL: this.config.connectionString || defaultConnectionString }, { overwrite: false }) const packageJson = await this.getStackablePackageJson()