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()